[issue35160] PyObjects initialized with PyObject_New have uninitialized pointers to set to 0x1

Serafeim Mellos report at bugs.python.org
Sun Nov 4 12:27:16 EST 2018


Serafeim Mellos <fim at mellos.io> added the comment:

Actually, I'm not so sure it's related to memory management after all judging by this (but I don't really know how the compilation part is supposed to work :)):


(gdb) watch *0x7ffff7ec0680
Hardware watchpoint 1: *0x7ffff7ec0680
(gdb) b Custom_dealloc
Breakpoint 2 at 0x7fffef9c4c50: file custom.c, line 16.
(gdb) run
[...]
Hardware watchpoint 1: *0x7ffff7ec0680

Old value = 0
New value = 1
dfs (c=c at entry=0x7fffffffd440, b=b at entry=0x7ffff7ec0660, a=a at entry=0x7fffffffd3b0, end=2) at Python/compile.c:4974
4974	        a->a_postorder[--j] = b;
(gdb) bt
#0  dfs (c=c at entry=0x7fffffffd440, b=b at entry=0x7ffff7ec0660, a=a at entry=0x7fffffffd3b0, end=2) at Python/compile.c:4974
#1  0x00000000004e9e86 in assemble (c=c at entry=0x7fffffffd440, addNone=<optimized out>) at Python/compile.c:5530
#2  0x00000000004f45c6 in compiler_mod (mod=0x9a86a8, c=0x7fffffffd440) at Python/compile.c:1641
#3  PyAST_CompileObject (mod=mod at entry=0x9a86a8, filename=filename at entry=0x7ffff7e510d8, flags=flags at entry=0x7fffffffd5e0, optimize=optimize at entry=-1, arena=arena at entry=0x7ffff7fb81e0)
    at Python/compile.c:345
#4  0x0000000000520025 in run_mod (arena=0x7ffff7fb81e0, flags=0x7fffffffd5e0, locals=0x7ffff7f38d80, globals=0x7ffff7f38d80, filename=0x7ffff7e510d8, mod=0x9a86a8)
    at Python/pythonrun.c:1028
#5  PyRun_InteractiveOneObjectEx (fp=fp at entry=0x7ffff749b8a0 <_IO_2_1_stdin_>, filename=filename at entry=0x7ffff7e510d8, flags=flags at entry=0x7fffffffd5e0) at Python/pythonrun.c:256
#6  0x0000000000520326 in PyRun_InteractiveLoopFlags (fp=fp at entry=0x7ffff749b8a0 <_IO_2_1_stdin_>, filename_str=filename_str at entry=0x5f1345 "<stdin>", flags=flags at entry=0x7fffffffd5e0)
    at Python/pythonrun.c:120
#7  0x000000000052049c in PyRun_AnyFileExFlags (fp=0x7ffff749b8a0 <_IO_2_1_stdin_>, filename=0x5f1345 "<stdin>", closeit=0, flags=0x7fffffffd5e0) at Python/pythonrun.c:78
#8  0x000000000042e0be in pymain_run_stdin (pymain=0x7fffffffd6f0, pymain=0x7fffffffd6f0, cf=0x7fffffffd5e0, config=0x922ea8) at Modules/main.c:1185
#9  pymain_run_python (interp=0x922e20, pymain=0x7fffffffd6f0) at Modules/main.c:1613
#10 pymain_main (pymain=0x7fffffffd6f0) at Modules/main.c:1758
#11 0x000000000042e309 in _Py_UnixMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:1795
#12 0x00007ffff711b4db in __libc_start_main () from /lib64/libc.so.6
#13 0x000000000042ae6a in _start ()
(gdb) frame
#0  dfs (c=c at entry=0x7fffffffd440, b=b at entry=0x7ffff7ec0660, a=a at entry=0x7fffffffd3b0, end=2) at Python/compile.c:4974
4974	        a->a_postorder[--j] = b;
(gdb) c
Continuing.
weird pointer has value of: 0x1
>>> 

Breakpoint 2, Custom_dealloc (self=0x7ffff7ec0660) at custom.c:16
16	{
(gdb) print(self->test_field)
$1 = (PyObject *) 0x1
(gdb) print(&self->test_field)
$2 = (PyObject **) 0x7ffff7ec0680

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35160>
_______________________________________


More information about the Python-bugs-list mailing list