Christian Heimes <li...@cheimes.de> added the comment:

The test_capi check for check_pyobject_freed_is_freed() is failing because 
FreeBSD 14.0 uses jemalloc, which performs its own dead memory cleaning. 
jemalloc's free() fills freed memory with byte 0x5a, which overrides Python's 
0xdd marker.

$ PYTHONMALLOC=malloc_debug gdb ./python
(gdb) b check_pyobject_freed_is_freed
(gdb) b _PyMem_DebugRawFree
(gdb) disable 2
(gdb) run -X faulthandler t.py
...
Breakpoint 1, check_pyobject_freed_is_freed (self=0x800f16fe0, 
_unused_args=0x0) at Modules/_testcapimodule.c:5032
5032        PyObject *op = PyObject_CallNoArgs((PyObject *)&PyBaseObject_Type);
(gdb) enable 2
(gdb) c
Continuing.

Breakpoint 2, _PyMem_DebugRawFree (ctx=0x5f8ad8 <_PyMem_Debug+96>, 
p=0x800e1a0a0) at Objects/obmalloc.c:2544
2544        if (p == NULL) {
(gdb) n
2549        uint8_t *q = (uint8_t *)p - 2*SST;  /* address returned from malloc 
*/
(gdb) n
2552        _PyMem_DebugCheckAddress(__func__, api->api_id, p);
(gdb) n
2553        nbytes = read_size_t(q);
(gdb) n
2554        nbytes += PYMEM_DEBUG_EXTRA_BYTES;
(gdb) n
2555        memset(q, PYMEM_DEADBYTE, nbytes);
(gdb) n
2556        api->alloc.free(api->alloc.ctx, q);
(gdb) p *q@20
$18 = '\335' <repeats 19 times>, <incomplete sequence \335>
(gdb) n
_PyMem_RawFree (ctx=0x0, ptr=0x800e1a090) at Objects/obmalloc.c:127
127     {
(gdb) n
128         free(ptr);
(gdb) p free
$19 = {void (void *)} 0x8006002c0 <free>
(gdb) s
__free (ptr=0x800e1a090) at jemalloc_jemalloc.c:2848
2848    jemalloc_jemalloc.c: No such file or directory.
(gdb) n
2851    in jemalloc_jemalloc.c
(gdb) 
2852    in jemalloc_jemalloc.c
...
(gdb) 
check_pyobject_freed_is_freed (self=0x800f16fe0, _unused_args=0x0) at 
Modules/_testcapimodule.c:5038
5038        Py_SET_REFCNT(op, 1);
(gdb) p *(char*)op@20
$23 = 'Z' <repeats 20 times>

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46263>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to