[Python-bugs-list] [Bug #110915] compiler core-dumps on illegal continue

noreply@sourceforge.net noreply@sourceforge.net
Tue, 29 Aug 2000 12:09:02 -0700


Bug #110915, was updated on 2000-Aug-02 05:13
Here is a current snapshot of the bug.

Project: Python
Category: Parser/Compiler
Status: Open
Resolution: None
Bug Group: Platform-specific
Priority: 7
Summary: compiler core-dumps on illegal continue

Details: On my RedHat 6.2 system, the latest CVS version of python still dumps
core on the following script:

-------------------------------------------------
def gentheta():
    while 1:
        try:
            continue
        finally:
            pass

def genkappa():
    if whatsmounted!='crystal':
        mountcrystal()
    while 1:
        if not inhibitmake:
            projtls.moveoutofway('kappa',dirok=1)
            os.mkdir('kappa')
        os.chdir('kappa')
        try:
            announce("Testing Kappa zero-point")
            # Use the detalign.vic produced by the dx calibration
            dal=os.path.join('..','dx','detalign.vic')
            if os.path.exists(dal):
                print "NOTE: Using detalign.vic from dx calibration"
                filecopy(dal,'detalign.vic')
            if not inhibitmake:
                status=os.system('calkappa make')
            else:
                status=os.system('calkappa')
            if status!=0:
                beeper.on()
                answer=command.question(root,'Calkappa Warnings',text='Calkappa issued some warnings and/or errors.\nPlease check what they are, and tell me what to do',
                                        strings=("Ignore them","Retry calkappa","Cancel and quit"))
                beeper.off()
                if answer==2:
                    cancel()
                if answer==1:
                    break
            if os.path.exists('instruct.txt'):
                beeper.on()
                answer=command.fixedfontquestion(
                    root,'Kappa missetting needs correction',
                    text=open('instruct.txt').read(),
                    strings=("I have now done this","I'm ignoring this for now","Cancel and quit"))
                beeper.off()
                if answer==2:
                    cancel()
                if answer==1:
                    break
            else:
                # No instructions means no correction required
                break
        finally:
            os.chdir('..')
-------------------------------------------
Any simplification in the second function makes the compiler
report the "SyntaxError: continue not properly in loop" in line 4.

Stack trace:
-------------------------------------------
no203[140]~%3% gdb =python     
GNU gdb 19991004
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) run x.py
Starting program: /usr/local/nonius/bin/python x.py

Program received signal SIGSEGV, Segmentation fault.
PyErr_NormalizeException (exc=0xbffff73c, val=0xbffff740, tb=0xbffff744)
    at errors.c:153
153             if (PyClass_Check(type)) {
(gdb) where
#0  PyErr_NormalizeException (exc=0xbffff73c, val=0xbffff740, tb=0xbffff744)
    at errors.c:153
#1  0x8063901 in PyErr_PrintEx (set_sys_last_vars=1) at pythonrun.c:672
#2  0x80638d6 in PyErr_Print () at pythonrun.c:663
#3  0x806368b in PyRun_SimpleFile (fp=0x80cb948, filename=0xbffff9a1 "x.py")
    at pythonrun.c:574
#4  0x806335d in PyRun_AnyFile (fp=0x80cb948, filename=0xbffff9a1 "x.py")
    at pythonrun.c:458
#5  0x80513c7 in Py_Main (argc=2, argv=0xbffff824) at main.c:271
#6  0x8050f56 in main (argc=2, argv=0xbffff824) at python.c:10
(gdb) The program is running.  Exit anyway? (y or n) y   


Follow-Ups:

Date: 2000-Aug-07 23:34
By: hooft

Comment:
Since today (compile.c 2.119) This no longer dumps core, but
gives the new "SystemError: lost syntax error" error message.
-------------------------------------------------------

Date: 2000-Aug-25 13:47
By: jhylton

Comment:
Is this bug now fixed?  The most recent comment suggests it is.  If so, please let me know and I'll close this report.

-------------------------------------------------------

Date: 2000-Aug-25 15:45
By: tim_one

Comment:
Well, while raising SystemError is friendlier than a core dump, at heart they're both ways to spell "the compiler is *really* confused" -- we shouldn't ever raise SystemError.
-------------------------------------------------------

Date: 2000-Aug-25 15:55
By: tim_one

Comment:
Note comment from compile.c:
/* This could happen if someone called PyErr_Clear() after
 * an error was reported above.  That's not supposed to
 * happen, but I just plugged one case and I'm not sure
 * there can't be others.  In that case, raise SystemError
 * so that at least it gets reported instead dumping core.
 */
PyErr_SetString(PyExc_SystemError, "lost syntax error");

So we got an internal error going here all right.  Can't reproduce under Windows, though.

-------------------------------------------------------

Date: 2000-Aug-29 12:09
By: jhylton

Comment:
Here's a stack trace showing the next PyErr_Clear call after SyntaxError is set.  Looks like it could be a GC bug.

#0  PyErr_Clear () at ../../Python/errors.c:225
#1  0x8098c1b in collect (young=0x80c9960, old=0x80c996c)
    at ../../Modules/gcmodule.c:447
#2  0x8098d1c in collect_generations () at ../../Modules/gcmodule.c:479
#3  0x8098d5f in _PyGC_Insert (op=0x811897c) at ../../Modules/gcmodule.c:498
#4  0x807ec14 in PyTuple_New (size=2) at ../../Objects/tupleobject.c:96
#5  0x8063d37 in do_mktuple (p_format=0xbffff1c8, p_va=0xbffff1cc, endchar=41, 
    n=2) at ../../Python/modsupport.c:220
#6  0x8063e13 in do_mkvalue (p_format=0xbffff1c8, p_va=0xbffff1cc)
    at ../../Python/modsupport.c:247
#7  0x806404d in Py_VaBuildValue (format=0x80ab8c0 "(OO)", va=0xbffff1ec)
    at ../../Python/modsupport.c:415
#8  0x8063feb in Py_BuildValue (format=0x80ab8c0 "(OO)")
    at ../../Python/modsupport.c:390
#9  0x805905d in com_add (c=0xbffff7bc, list=0x811738c, dict=0x8116eb4, 
    v=0x8118948) at ../../Python/compile.c:645
#10 0x805912d in com_addconst (c=0xbffff7bc, v=0x8118948)
    at ../../Python/compile.c:674
#11 0x805a1ca in com_argument (c=0xbffff7bc, n=0x81206b8, pkeywords=0xbffff270)
    at ../../Python/compile.c:1299
#12 0x805a2b9 in com_call_function (c=0xbffff7bc, n=0x811fd94)
    at ../../Python/compile.c:1332
#13 0x805a78a in com_apply_trailer (c=0xbffff7bc, n=0x811fd08)
    at ../../Python/compile.c:1515
#14 0x805a830 in com_power (c=0xbffff7bc, n=0x811fc80)
    at ../../Python/compile.c:1543
#15 0x805a8a7 in com_factor (c=0xbffff7bc, n=0x811fc60)
    at ../../Python/compile.c:1564
#16 0x805a8c1 in com_term (c=0xbffff7bc, n=0x811fc40)
    at ../../Python/compile.c:1574
#17 0x805a98d in com_arith_expr (c=0xbffff7bc, n=0x811fc20)
    at ../../Python/compile.c:1603
#18 0x805aa39 in com_shift_expr (c=0xbffff7bc, n=0x811fc00)
    at ../../Python/compile.c:1629
#19 0x805aae9 in com_and_expr (c=0xbffff7bc, n=0x811fbe0)
    at ../../Python/compile.c:1655
#20 0x805ab81 in com_xor_expr (c=0xbffff7bc, n=0x811fbc0)
    at ../../Python/compile.c:1677
#21 0x805ac19 in com_expr (c=0xbffff7bc, n=0x811fba0)
    at ../../Python/compile.c:1699
#22 0x805ade4 in com_comparison (c=0xbffff7bc, n=0x811fb80)
    at ../../Python/compile.c:1753
#23 0x805af31 in com_not_test (c=0xbffff7bc, n=0x811fb60)
    at ../../Python/compile.c:1828
#24 0x805af9e in com_and_test (c=0xbffff7bc, n=0x811fb40)
    at ../../Python/compile.c:1845

-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=110915&group_id=5470