Back to index

enigmail  1.4.3
Functions | Variables
find_OOM_errors Namespace Reference

Functions

def run
 Utility functions.
def get_js_files
def in_blacklist
 Blacklisting.
def add_to_blacklist
def count_lines
def clean_voutput
 Output cleaning.
def remove_failed_allocation_backtraces
def clean_output

Variables

string usage
string help
string command_template = 'shell/js'
 Consts, etc.
dictionary blacklist = {}
tuple whitelist = set()
tuple parser = OptionParser(usage=usage)
 Program.
string type = "int"
list files = ["../jit-test/tests/arguments/args-createontrace.js"]
tuple log = file("../OOM_log", "w")
int num_failures = 0
tuple command = (command_template + ' -O')
tuple max = re.match(".*OOM max count: (\d+).*", out, flags=re.DOTALL)
tuple problem = str((out, err, exit))
 The regression tests ends above.
string vcommand = "valgrind --dsymutil=yes -q --log-file=OOM_valgrind_log_file "
tuple vout = file("OOM_valgrind_log_file")
tuple sans_alloc_sites = remove_failed_allocation_backtraces(vout)
tuple double_free = err.find("pointer being freed was not allocated")
tuple oom_detected = err.find("out of memory")
tuple multiple_oom_detected = err.find("out of memory\nout of memory")
int segfault_detected = 11
 expected_num_failures = OPTIONS.regression
 all
 pipe

Function Documentation

Definition at line 85 of file find_OOM_errors.py.

00085 
00086 def add_to_blacklist(sig):
00087   blacklist[sig] = blacklist.get(sig, 0)
00088   blacklist[sig] += 1
00089 
# How often is a particular lines important for this.

Definition at line 156 of file find_OOM_errors.py.

00156 
00157 def clean_output(err):
00158   err = re.sub(r"^js\(\d+,0x[0-9a-f]+\) malloc: \*\*\* error for object 0x[0-9a-f]+: pointer being freed was not allocated\n\*\*\* set a breakppoint in malloc_error_break to debug\n$", "pointer being freed was not allocated", err, flags=re.MULTILINE)
00159 
00160   return err
00161 

Output cleaning.

Definition at line 113 of file find_OOM_errors.py.

00113 
00114 def clean_voutput(err):
00115   # Skip what we can't reproduce
00116   err = re.sub(r"^--\d+-- run: /usr/bin/dsymutil \"shell/js\"$", "", err, flags=re.MULTILINE)
00117   err = re.sub(r"^==\d+==", "", err, flags=re.MULTILINE)
00118   err = re.sub(r"^\*\*\d+\*\*", "", err, flags=re.MULTILINE)
00119   err = re.sub(r"^\s+by 0x[0-9A-Fa-f]+: ", "by: ", err, flags=re.MULTILINE)
00120   err = re.sub(r"^\s+at 0x[0-9A-Fa-f]+: ", "at: ", err, flags=re.MULTILINE)
00121   err = re.sub(r"(^\s+Address 0x)[0-9A-Fa-f]+( is not stack'd)", r"\1\2", err, flags=re.MULTILINE)
00122   err = re.sub(r"(^\s+Invalid write of size )\d+", r"\1x", err, flags=re.MULTILINE)
00123   err = re.sub(r"(^\s+Invalid read of size )\d+", r"\1x", err, flags=re.MULTILINE)
00124   err = re.sub(r"(^\s+Address 0x)[0-9A-Fa-f]+( is )\d+( bytes inside a block of size )[0-9,]+( free'd)", r"\1\2\3\4", err, flags=re.MULTILINE)
00125 
00126   # Skip the repeating bit due to the segfault
00127   lines = []
00128   for l in err.split('\n'):
00129     if l == " Process terminating with default action of signal 11 (SIGSEGV)":
00130       break
00131     lines.append(l)
00132   err = '\n'.join(lines)
00133 
00134   return err

Keep track of the amount of times individual lines occur, in order to
   prioritize the errors which occur most frequently.

Definition at line 90 of file find_OOM_errors.py.

00090 
00091 def count_lines():
00092   """Keep track of the amount of times individual lines occur, in order to
00093      prioritize the errors which occur most frequently."""
00094   counts = {}
00095   for string,count in blacklist.items():
00096     for line in string.split("\n"):
00097       counts[line] = counts.get(line, 0) + count
00098 
00099   lines = []
00100   for k,v in counts.items():
00101     lines.append("%6d: %s" % (v,k))
00102 
00103   lines.sort()
00104 
00105   countlog = file("../OOM_count_log", "w")
00106   countlog.write("\n".join(lines))
00107   countlog.flush()
00108   countlog.close()
00109 

Definition at line 71 of file find_OOM_errors.py.

00071 
00072 def get_js_files():
00073   (out, err, exit) = run('find ../jit-test/tests -name "*.js"')
00074   if (err, exit) != ("", 0):
00075     sys.exit("Wrong directory, run from an objdir")
00076   return out.split()
00077 
00078 

Here is the call graph for this function:

Blacklisting.

Definition at line 82 of file find_OOM_errors.py.

00082 
00083 def in_blacklist(sig):
00084   return sig in blacklist

Definition at line 135 of file find_OOM_errors.py.

00135 
00136 def remove_failed_allocation_backtraces(err):
00137   lines = []
00138 
00139   add = True
00140   for l in err.split('\n'):
00141 
00142     # Set start and end conditions for including text
00143     if l == " The site of the failed allocation is:":
00144       add = False
00145     elif l[:2] not in ['by: ', 'at:']:
00146       add = True
00147 
00148     if add:
00149       lines.append(l)
00150 
00151 
00152   err = '\n'.join(lines)
00153 
00154   return err
00155 

def find_OOM_errors.run (   args,
  stdin = None 
)

Utility functions.

Definition at line 28 of file find_OOM_errors.py.

00028 
00029 def run(args, stdin=None):
00030   class ThreadWorker(threading.Thread):
00031     def __init__(self, pipe):
00032       super(ThreadWorker, self).__init__()
00033       self.all = ""
00034       self.pipe = pipe
00035       self.setDaemon(True)
00036 
00037     def run(self):
00038       while True:
00039         line = self.pipe.readline()
00040         if line == '': break
00041         else:
00042           self.all += line
00043 
00044   try:
00045     if type(args) == str:
00046       args = shlex.split(args)
00047 
00048     args = [str(a) for a in args] # convert to strs
00049 
00050     stdin_pipe = subprocess.PIPE if stdin else None
00051     proc = subprocess.Popen(args, stdin=stdin_pipe, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
00052     if stdin_pipe:
00053       proc.stdin.write(stdin)
00054       proc.stdin.close()
00055 
00056     stdout_worker = ThreadWorker(proc.stdout)
00057     stderr_worker = ThreadWorker(proc.stderr)
00058     stdout_worker.start()
00059     stderr_worker.start()
00060 
00061     proc.wait()
00062     stdout_worker.join()
00063     stderr_worker.join()
00064 
00065   except KeyboardInterrupt, e:
00066     sys.exit(-1)
00067 
00068   stdout, stderr = stdout_worker.all, stderr_worker.all
00069   result = (stdout, stderr, proc.returncode)
00070   return result

Here is the caller graph for this function:


Variable Documentation

Definition at line 32 of file find_OOM_errors.py.

dictionary find_OOM_errors.blacklist = {}

Definition at line 177 of file find_OOM_errors.py.

Definition at line 221 of file find_OOM_errors.py.

string find_OOM_errors.command_template = 'shell/js'

Consts, etc.

Definition at line 166 of file find_OOM_errors.py.

tuple find_OOM_errors.double_free = err.find("pointer being freed was not allocated")

Definition at line 292 of file find_OOM_errors.py.

Definition at line 326 of file find_OOM_errors.py.

list find_OOM_errors.files = ["../jit-test/tests/arguments/args-createontrace.js"]

Definition at line 203 of file find_OOM_errors.py.

Initial value:
00001 """Check for regressions only. This runs a set of files with a known
00002 number of OOM errors (specified by REGRESSION_COUNT), and exits with a non-zero
00003 result if more or less errors are found. See js/src/Makefile.in for invocation.
00004 """

Definition at line 9 of file find_OOM_errors.py.

tuple find_OOM_errors.log = file("../OOM_log", "w")

Definition at line 214 of file find_OOM_errors.py.

tuple find_OOM_errors.max = re.match(".*OOM max count: (\d+).*", out, flags=re.DOTALL)

Definition at line 223 of file find_OOM_errors.py.

tuple find_OOM_errors.multiple_oom_detected = err.find("out of memory\nout of memory")

Definition at line 294 of file find_OOM_errors.py.

Definition at line 217 of file find_OOM_errors.py.

tuple find_OOM_errors.oom_detected = err.find("out of memory")

Definition at line 293 of file find_OOM_errors.py.

tuple find_OOM_errors.parser = OptionParser(usage=usage)

Program.

Definition at line 192 of file find_OOM_errors.py.

Definition at line 33 of file find_OOM_errors.py.

tuple find_OOM_errors.problem = str((out, err, exit))

The regression tests ends above.

The rest of this is for running the script manually.

Definition at line 255 of file find_OOM_errors.py.

Definition at line 268 of file find_OOM_errors.py.

Definition at line 295 of file find_OOM_errors.py.

string find_OOM_errors.type = "int"

Definition at line 194 of file find_OOM_errors.py.

Initial value:
00001 """%prog: A test for OOM conditions in the shell.
00002 
00003 %prog finds segfaults and other errors caused by incorrect handling of
00004 allocation during OOM (out-of-memory) conditions.
00005 """

Definition at line 3 of file find_OOM_errors.py.

string find_OOM_errors.vcommand = "valgrind --dsymutil=yes -q --log-file=OOM_valgrind_log_file "

Definition at line 264 of file find_OOM_errors.py.

tuple find_OOM_errors.vout = file("OOM_valgrind_log_file")

Definition at line 266 of file find_OOM_errors.py.

Definition at line 181 of file find_OOM_errors.py.