[Python-Dev] serious bug in new import X as Y code

Sjoerd Mullender sjoerd@oratrix.nl
Fri, 18 Aug 2000 11:42:38 +0200


Your changes for the import X as Y feature introduced a serious bug:
I can no longer run Python at all.

The problem is that in line 2150 of compile.c com_addopname is called
with a NULL last argument, and the firat thing com_addopname does is
indirect off of that very argument.  On my machine (and on many other
machines) that results in a core dump.

In case it helps, here is the stack trace.  The crash happens when
importing site.py.  I have not made any changes to my site.py.

>  0 com_addopname(c = 0x7fff1e20, op = 90, n = (nil)) ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":738, 0x1006cb58]
   1 com_import_stmt(c = 0x7fff1e20, n = 0x101e2ad0) ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":2150, 0x10071ecc]
   2 com_node(c = 0x7fff1e20, n = 0x101e2ad0) ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":2903, 0x10074764]
   3 com_node(c = 0x7fff1e20, n = 0x101eaf68) ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":2855, 0x10074540]
   4 com_node(c = 0x7fff1e20, n = 0x101e2908) ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":2864, 0x100745b0]
   5 com_node(c = 0x7fff1e20, n = 0x1020d450) ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":2855, 0x10074540]
   6 com_file_input(c = 0x7fff1e20, n = 0x101e28f0) ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":3137, 0x10075324]
   7 compile_node(c = 0x7fff1e20, n = 0x101e28f0) ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":3241, 0x100759c0]
   8 jcompile(n = 0x101e28f0, filename = 0x7fff2430 = "./../Lib/site.py", base = (nil)) ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":3400, 0x10076058]
   9 PyNode_Compile(n = 0x101e28f0, filename = 0x7fff2430 = "./../Lib/site.py") ["/ufs/sjoerd/src/Python/dist/src/Python/compile.c":3378, 0x10075f7c]
   10 parse_source_module(pathname = 0x7fff2430 = "./../Lib/site.py", fp = 0xfb563c8) ["/ufs/sjoerd/src/Python/dist/src/Python/import.c":632, 0x100151a4]
   11 load_source_module(name = 0x7fff28d8 = "site", pathname = 0x7fff2430 = "./../Lib/site.py", fp = 0xfb563c8) ["/ufs/sjoerd/src/Python/dist/src/Python/import.c":722, 0x100154c8]
   12 load_module(name = 0x7fff28d8 = "site", fp = 0xfb563c8, buf = 0x7fff2430 = "./../Lib/site.py", type = 1) ["/ufs/sjoerd/src/Python/dist/src/Python/import.c":1199, 0x1001629c]
   13 import_submodule(mod = 0x101b8478, subname = 0x7fff28d8 = "site", fullname = 0x7fff28d8 = "site") ["/ufs/sjoerd/src/Python/dist/src/Python/import.c":1727, 0x10017dc4]
   14 load_next(mod = 0x101b8478, altmod = 0x101b8478, p_name = 0x7fff2d04, buf = 0x7fff28d8 = "site", p_buflen = 0x7fff28d0) ["/ufs/sjoerd/src/Python/dist/src/Python/import.c":1583, 0x100174c0]
   15 import_module_ex(name = (nil), globals = (nil), locals = (nil), fromlist = (nil)) ["/ufs/sjoerd/src/Python/dist/src/Python/import.c":1434, 0x10016d04]
   16 PyImport_ImportModuleEx(name = 0x101d9450 = "site", globals = (nil), locals = (nil), fromlist = (nil)) ["/ufs/sjoerd/src/Python/dist/src/Python/import.c":1475, 0x10016fe0]
   17 PyImport_ImportModule(name = 0x101d9450 = "site") ["/ufs/sjoerd/src/Python/dist/src/Python/import.c":1408, 0x10016c64]
   18 initsite() ["/ufs/sjoerd/src/Python/dist/src/Python/pythonrun.c":429, 0x10053148]
   19 Py_Initialize() ["/ufs/sjoerd/src/Python/dist/src/Python/pythonrun.c":166, 0x100529c8]
   20 Py_Main(argc = 1, argv = 0x7fff2ec4) ["/ufs/sjoerd/src/Python/dist/src/Modules/main.c":229, 0x10013690]
   21 main(argc = 1, argv = 0x7fff2ec4) ["/ufs/sjoerd/src/Python/dist/src/Modules/python.c":10, 0x10012f24]
   22 __start() ["/xlv55/kudzu-apr12/work/irix/lib/libc/libc_n32_M4/csu/crt1text.s":177, 0x10012ec8]

-- Sjoerd Mullender <sjoerd.mullender@oratrix.com>