~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to config/find_vanilla_new_calls

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# /bin/bash
2
 
 
3
 
#----------------------------------------------------------------------------
4
 
# We must avoid using the vanilla new/new[] operators (and consequently, the
5
 
# vanilla delete/delete[] operators) in SpiderMonkey, see bug 624878 for why.
6
 
#
7
 
# This script:
8
 
# - Detects if any of the vanilla new/new[] operators are used in a file.
9
 
#   Its exit code is 1 if it found some, and 0 if it didn't.
10
 
# - Doesn't detect delete/delete[] because it appears they can be present
11
 
#   somehow due to virtual destructors, but this is ok because vanilla
12
 
#   delete/delete[] calls don't make sense without corresponding new/new[]
13
 
#   calls, and any explicit calls will be caught by Valgrind's mismatched
14
 
#   alloc/free checking.
15
 
# - Doesn't detect the 'nothrow' variants, which are ok but probably still
16
 
#   best avoided.
17
 
# - Is designed to only run on Linux (though it may also work on Mac);  one
18
 
#   platform will be enough to catch any violations.
19
 
#
20
 
# If this script fails:
21
 
# - You need to find the uses of vanilla new/delete and replace them with
22
 
#   {js::OffTheBooks,JSContext,JSRuntime}::{new_,/array_new}.
23
 
# - Run this script on each of the .o files, that should narrow it down.
24
 
# - After that, one way to find them is to run 'objdump -r -C' on the
25
 
#   relevant .o files.  For example, you might search for 'operator new' and
26
 
#   find a record like this:
27
 
#
28
 
#  RELOCATION RECORDS FOR [.text._ZN3JSC14ExecutablePool6createEj]:
29
 
#  OFFSET   TYPE              VALUE
30
 
#  00000009 R_386_PC32        __i686.get_pc_thunk.bx
31
 
#  0000000f R_386_GOTPC       _GLOBAL_OFFSET_TABLE_
32
 
#  0000001b R_386_PLT32       operator new(unsigned int)
33
 
#  0000002e R_386_PC32        JSC::ExecutablePool::ExecutablePool(unsigned int)
34
 
#  0000004a R_386_PC32        JSC::ExecutablePool::~ExecutablePool()
35
 
#  00000052 R_386_PLT32       operator delete(void*)
36
 
#
37
 
#   This says that vanilla 'new' and 'delete' are both used in
38
 
#   JSC::ExecutablePool::create(unsigned int).  This doesn't always work,
39
 
#   though.  (Nb: use 'c++filt' to demangle names like
40
 
#   _ZN3JSC14ExecutablePool6createEj.)
41
 
#
42
 
# If that doesn't work, use grep.
43
 
#----------------------------------------------------------------------------
44
 
 
45
 
if [ -z $1 ] ; then
46
 
    echo "usage: find_vanilla_new_calls <file>"
47
 
    exit 1
48
 
fi
49
 
 
50
 
file=$1
51
 
 
52
 
if [ ! -f $file ] ; then
53
 
    echo "TEST-UNEXPECTED-FAIL | find_vanilla_new_calls | file '$file' not found"
54
 
    exit 1
55
 
fi
56
 
 
57
 
tmpfile1=`mktemp`
58
 
tmpfile2=`mktemp`
59
 
nm -C $file > $tmpfile1
60
 
 
61
 
# Need to double-escape '[' and ']' to stop grep from interpreting them
62
 
# specially.
63
 
grep 'operator new(unsigned int)'        $tmpfile1 >> $tmpfile2
64
 
grep 'operator new(unsigned long)'       $tmpfile1 >> $tmpfile2
65
 
grep 'operator new\\[\\](unsigned int)'  $tmpfile1 >> $tmpfile2
66
 
grep 'operator new\\[\\](unsigned long)' $tmpfile1 >> $tmpfile2
67
 
rm -f $tmpfile1
68
 
 
69
 
if [ -s $tmpfile2 ] ; then
70
 
    echo "TEST-UNEXPECTED-FAIL | find_vanilla_new_calls | found calls are listed below"
71
 
    cat $tmpfile2
72
 
    echo
73
 
    rm -f $tmpfile2
74
 
    exit 1
75
 
fi
76
 
 
77
 
echo "TEST-PASS | find_vanilla_new_calls | ok"
78
 
echo
79
 
 
80
 
exit 0