diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-01-10 07:49:41 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-01-10 07:49:41 (GMT) |
commit | 8cc4ef561c1ba8f36520396c6f631764b55f4643 (patch) | |
tree | eddaba777527be8e2cf2a95996c5daef52ddfe48 /Lib/test/crashers | |
parent | 88bbd73d0763bb4df48d45791dafbef76c2e17a5 (diff) | |
download | cpython-8cc4ef561c1ba8f36520396c6f631764b55f4643.zip cpython-8cc4ef561c1ba8f36520396c6f631764b55f4643.tar.gz cpython-8cc4ef561c1ba8f36520396c6f631764b55f4643.tar.bz2 |
As I threatened on python-dev, add a directory which contains all known
bugs which cause the interpreter to crash. I'm sure we can find a few
more. Many missing bugs deal with variations on unchecked infinite recursion
(like coerce.py).
Diffstat (limited to 'Lib/test/crashers')
-rw-r--r-- | Lib/test/crashers/README | 15 | ||||
-rw-r--r-- | Lib/test/crashers/coerce.py | 9 | ||||
-rw-r--r-- | Lib/test/crashers/weakref_in_del.py | 17 | ||||
-rw-r--r-- | Lib/test/crashers/xml_parsers.py | 56 |
4 files changed, 97 insertions, 0 deletions
diff --git a/Lib/test/crashers/README b/Lib/test/crashers/README new file mode 100644 index 0000000..9369282 --- /dev/null +++ b/Lib/test/crashers/README @@ -0,0 +1,15 @@ +This directory only contains tests for outstanding bugs that cause +the interpreter to segfault. Ideally this directory should always +be empty. Sometimes it may not be easy to fix the underlying cause. + +Each test should fail when run from the command line: + + ./python Lib/test/crashers/weakref_in_del.py + +Each test should have a link to the bug report: + + # http://python.org/sf/BUG# + +Put as much info into a docstring or comments to help determine +the cause of the failure. Particularly note if the cause is +system or environment dependent and what the variables are. diff --git a/Lib/test/crashers/coerce.py b/Lib/test/crashers/coerce.py new file mode 100644 index 0000000..574956b --- /dev/null +++ b/Lib/test/crashers/coerce.py @@ -0,0 +1,9 @@ + +# http://python.org/sf/992017 + +class foo: + def __coerce__(self, other): + return other, self + +if __name__ == '__main__': + foo()+1 # segfault: infinite recursion in C diff --git a/Lib/test/crashers/weakref_in_del.py b/Lib/test/crashers/weakref_in_del.py new file mode 100644 index 0000000..d00937f --- /dev/null +++ b/Lib/test/crashers/weakref_in_del.py @@ -0,0 +1,17 @@ +import weakref + +# http://python.org/sf/1377858 + +ref = None + +def test_weakref_in_del(): + class Target(object): + def __del__(self): + global ref + ref = weakref.ref(self) + + w = Target() + +if __name__ == '__main__': + test_weakref_in_del() + diff --git a/Lib/test/crashers/xml_parsers.py b/Lib/test/crashers/xml_parsers.py new file mode 100644 index 0000000..89db5c9 --- /dev/null +++ b/Lib/test/crashers/xml_parsers.py @@ -0,0 +1,56 @@ +from xml.parsers import expat + +# http://python.org/sf/1296433 + +def test_parse_only_xml_data(): + # + xml = "<?xml version='1.0' encoding='iso8859'?><s>%s</s>" % ('a' * 1025) + # this one doesn't crash + #xml = "<?xml version='1.0'?><s>%s</s>" % ('a' * 10000) + + def handler(text): + raise Exception + + parser = expat.ParserCreate() + parser.CharacterDataHandler = handler + + try: + parser.Parse(xml) + except: + pass + +if __name__ == '__main__': + test_parse_only_xml_data() + +# Invalid read of size 4 +# at 0x43F936: PyObject_Free (obmalloc.c:735) +# by 0x45A7C7: unicode_dealloc (unicodeobject.c:246) +# by 0x1299021D: PyUnknownEncodingHandler (pyexpat.c:1314) +# by 0x12993A66: processXmlDecl (xmlparse.c:3330) +# by 0x12999211: doProlog (xmlparse.c:3678) +# by 0x1299C3F0: prologInitProcessor (xmlparse.c:3550) +# by 0x12991EA3: XML_ParseBuffer (xmlparse.c:1562) +# by 0x1298F8EC: xmlparse_Parse (pyexpat.c:895) +# by 0x47B3A1: PyEval_EvalFrameEx (ceval.c:3565) +# by 0x47CCAC: PyEval_EvalCodeEx (ceval.c:2739) +# by 0x47CDE1: PyEval_EvalCode (ceval.c:490) +# by 0x499820: PyRun_SimpleFileExFlags (pythonrun.c:1198) +# by 0x4117F1: Py_Main (main.c:492) +# by 0x12476D1F: __libc_start_main (in /lib/libc-2.3.5.so) +# by 0x410DC9: (within /home/neal/build/python/svn/clean/python) +# Address 0x12704020 is 264 bytes inside a block of size 592 free'd +# at 0x11B1BA8A: free (vg_replace_malloc.c:235) +# by 0x124B5F18: (within /lib/libc-2.3.5.so) +# by 0x48DE43: find_module (import.c:1320) +# by 0x48E997: import_submodule (import.c:2249) +# by 0x48EC15: load_next (import.c:2083) +# by 0x48F091: import_module_ex (import.c:1914) +# by 0x48F385: PyImport_ImportModuleEx (import.c:1955) +# by 0x46D070: builtin___import__ (bltinmodule.c:44) +# by 0x4186CF: PyObject_Call (abstract.c:1777) +# by 0x474E9B: PyEval_CallObjectWithKeywords (ceval.c:3432) +# by 0x47928E: PyEval_EvalFrameEx (ceval.c:2038) +# by 0x47CCAC: PyEval_EvalCodeEx (ceval.c:2739) +# by 0x47CDE1: PyEval_EvalCode (ceval.c:490) +# by 0x48D0F7: PyImport_ExecCodeModuleEx (import.c:635) +# by 0x48D4F4: load_source_module (import.c:913) |