[Compiler-sig] ast branch

Neal Norwitz neal@metaslash.com
Tue, 01 Apr 2003 19:02:57 -0500


On Tue, Apr 01, 2003 at 06:46:35PM -0500, Jeremy Hylton wrote:
> I guess I better figure out how to use Valgrind, because it diagnoses
> problems faster than I do :-).

:-) It's very easy.  Build, install, run:

        valgrind --show-reachable=yes --num-callers=15 --leak-check=yes ./python

I run under script so I can catch the output, redirecting doesn't work if
there's a crash because valgrind does some funny stuff.

> The PyObject_Free(mod) fails in a debug build.
> file_input containing 38 statements
> Debug memory block at address p=0x8144f28:
>     3688618971 bytes originally requested
>     The 4 pad bytes at p-4 are not all FORBIDDENBYTE (0xfb):
>         at p-4: 0x11 *** OUCH
>         at p-3: 0x00 *** OUCH
>         at p-2: 0x00 *** OUCH
>         at p-1: 0x00 *** OUCH
>     Because memory is corrupted at the start, the count of bytes
> requested
>        may be bogus, and checking the trailing pad bytes may segfault.
>     The 4 pad bytes at tail=0xe3f02b03 are Segmentation fault (core
> dumped)

Hmmm, I'm also using debug, but don't get the problem when running
under valgrind or not.  I have no outstanding changes.  But it could
be the read from uninitialized memory is behaving differently on
our boxes too.

> Also, the compiler_use_next_block() after a jump is not the right answer
> in the long run.  The next part means that there is a control flow from
> the previous block to the next block.  If the previous block ends with a
> jump, there's clearly no implicit control flow to the next block.  There
> must be some other way to fix the problem, but I'm not sure what it is.

Ok.  I just made it consistent.  It was 2 and 2 I think.  I think there
is also a lot more memory that stays in use after it is needed.

==7289== 37348 bytes in 7274 blocks are still reachable in loss record 237 of 241
==7289==    at 0x40168A70: malloc (vg_clientfuncs.c:100)
==7289==    by 0x8055036: parsetok (Parser/parsetok.c:128)
==7289==    by 0x8054F51: PyParser_ParseFileFlags (Parser/parsetok.c:81)
==7289==    by 0x80C246A: PyParser_ASTFromFile (Python/pythonrun.c:1099)
==7289==    by 0x80B6E63: parse_source_module (Python/import.c:660)
==7289==    by 0x80B7115: load_source_module (Python/import.c:782)
==7289==    by 0x80B7EDC: load_module (Python/import.c:1455)
==7289==    by 0x80B95A5: import_submodule (Python/import.c:1994)
==7289==    by 0x80B8D47: load_next (Python/import.c:1850)
==7289==    by 0x80B869A: import_module_ex (Python/import.c:1701)
==7289==    by 0x80B89DF: PyImport_ImportModuleEx (Python/import.c:1742)
==7289==    by 0x809355C: builtin___import__ (Python/bltinmodule.c:40)
==7289==    by 0x80F9A6D: PyCFunction_Call (Objects/methodobject.c:80)
==7289==    by 0x80E07EE: PyObject_Call (Objects/abstract.c:1688)
==7289==    by 0x80A6E24: PyEval_CallObjectWithKeywords (Python/ceval.c:3026)
==7289== 
==7289== 41560 bytes in 2078 blocks are still reachable in loss record 238 of 241
==7289==    at 0x40168A70: malloc (vg_clientfuncs.c:100)
==7289==    by 0x40168FF0: realloc (vg_clientfuncs.c:265)
==7289==    by 0x8105B20: PyNode_AddChild (Parser/node.c:35)
==7289==    by 0x80DBF99: shift (Parser/parser.c:112)
==7289==    by 0x80DC356: PyParser_AddToken (Parser/parser.c:244)
==7289==    by 0x80550AB: parsetok (Parser/parsetok.c:148)
==7289==    by 0x8054F51: PyParser_ParseFileFlags (Parser/parsetok.c:81)
==7289==    by 0x80C246A: PyParser_ASTFromFile (Python/pythonrun.c:1099)
==7289==    by 0x80B6E63: parse_source_module (Python/import.c:660)
==7289==    by 0x80B7115: load_source_module (Python/import.c:782)
==7289==    by 0x80B7EDC: load_module (Python/import.c:1455)
==7289==    by 0x80B95A5: import_submodule (Python/import.c:1994)
==7289==    by 0x80B8D47: load_next (Python/import.c:1850)
==7289==    by 0x80B869A: import_module_ex (Python/import.c:1701)
==7289==    by 0x80B89DF: PyImport_ImportModuleEx (Python/import.c:1742)
==7289== 
==7289== 124740 bytes in 1576 blocks are still reachable in loss record 239 of 241
==7289==    at 0x40169079: realloc (vg_clientfuncs.c:273)
==7289==    by 0x8105B20: PyNode_AddChild (Parser/node.c:35)
==7289==    by 0x80DC00B: push (Parser/parser.c:126)
==7289==    by 0x80DC2E0: PyParser_AddToken (Parser/parser.c:234)
==7289==    by 0x80550AB: parsetok (Parser/parsetok.c:148)
==7289==    by 0x8054F51: PyParser_ParseFileFlags (Parser/parsetok.c:81)
==7289==    by 0x80C246A: PyParser_ASTFromFile (Python/pythonrun.c:1099)
==7289==    by 0x80B6E63: parse_source_module (Python/import.c:660)
==7289==    by 0x80B7115: load_source_module (Python/import.c:782)
==7289==    by 0x80B7EDC: load_module (Python/import.c:1455)
==7289==    by 0x80B95A5: import_submodule (Python/import.c:1994)
==7289==    by 0x80B8D47: load_next (Python/import.c:1850)
==7289==    by 0x80B869A: import_module_ex (Python/import.c:1701)
==7289==    by 0x80B89DF: PyImport_ImportModuleEx (Python/import.c:1742)
==7289==    by 0x809355C: builtin___import__ (Python/bltinmodule.c:40)
==7289== 
==7289== 141480 bytes in 1859 blocks are still reachable in loss record 240 of 241
==7289==    at 0x40169079: realloc (vg_clientfuncs.c:273)
==7289==    by 0x8105B20: PyNode_AddChild (Parser/node.c:35)
==7289==    by 0x80DBF99: shift (Parser/parser.c:112)
==7289==    by 0x80DC356: PyParser_AddToken (Parser/parser.c:244)
==7289==    by 0x80550AB: parsetok (Parser/parsetok.c:148)
==7289==    by 0x8054F51: PyParser_ParseFileFlags (Parser/parsetok.c:81)
==7289==    by 0x80C246A: PyParser_ASTFromFile (Python/pythonrun.c:1099)
==7289==    by 0x80B6E63: parse_source_module (Python/import.c:660)
==7289==    by 0x80B7115: load_source_module (Python/import.c:782)
==7289==    by 0x80B7EDC: load_module (Python/import.c:1455)
==7289==    by 0x80B95A5: import_submodule (Python/import.c:1994)
==7289==    by 0x80B8D47: load_next (Python/import.c:1850)
==7289==    by 0x80B869A: import_module_ex (Python/import.c:1701)
==7289==    by 0x80B89DF: PyImport_ImportModuleEx (Python/import.c:1742)
==7289==    by 0x809355C: builtin___import__ (Python/bltinmodule.c:40)
==7289== 
==7289== 466920 bytes in 23346 blocks are still reachable in loss record 241 of 241
==7289==    at 0x40168A70: malloc (vg_clientfuncs.c:100)
==7289==    by 0x40168FF0: realloc (vg_clientfuncs.c:265)
==7289==    by 0x8105B20: PyNode_AddChild (Parser/node.c:35)
==7289==    by 0x80DC00B: push (Parser/parser.c:126)
==7289==    by 0x80DC2E0: PyParser_AddToken (Parser/parser.c:234)
==7289==    by 0x80550AB: parsetok (Parser/parsetok.c:148)
==7289==    by 0x8054F51: PyParser_ParseFileFlags (Parser/parsetok.c:81)
==7289==    by 0x80C246A: PyParser_ASTFromFile (Python/pythonrun.c:1099)
==7289==    by 0x80B6E63: parse_source_module (Python/import.c:660)
==7289==    by 0x80B7115: load_source_module (Python/import.c:782)
==7289==    by 0x80B7EDC: load_module (Python/import.c:1455)
==7289==    by 0x80B95A5: import_submodule (Python/import.c:1994)
==7289==    by 0x80B8D47: load_next (Python/import.c:1850)
==7289==    by 0x80B869A: import_module_ex (Python/import.c:1701)
==7289==    by 0x80B89DF: PyImport_ImportModuleEx (Python/import.c:1742)