bpo-29564:_PyMem_DumpTraceback() suggests enabling tracemalloc (GH-10… · python/cpython@ae88781 (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -534,6 +534,8 @@ def test_buffer_overflow(self):
534 534 r" The block was made by call #[0-9]+ to debug malloc/realloc.\n"
535 535 r" Data at p: cb cb cb .*\n"
536 536 r"\n"
537 +r"Enable tracemalloc to get the memory block allocation traceback\n"
538 +r"\n"
537 539 r"Fatal Python error: bad trailing pad byte")
538 540 regex = regex.format(ptr=self.PTR_REGEX)
539 541 regex = re.compile(regex, flags=re.DOTALL)
@@ -548,6 +550,8 @@ def test_api_misuse(self):
548 550 r" The block was made by call #[0-9]+ to debug malloc/realloc.\n"
549 551 r" Data at p: cb cb cb .*\n"
550 552 r"\n"
553 +r"Enable tracemalloc to get the memory block allocation traceback\n"
554 +r"\n"
551 555 r"Fatal Python error: bad ID: Allocated using API 'm', verified using API 'r'\n")
552 556 regex = regex.format(ptr=self.PTR_REGEX)
553 557 self.assertRegex(out, regex)
Original file line number Diff line number Diff line change
@@ -1492,6 +1492,12 @@ _PyMem_DumpTraceback(int fd, const void *ptr)
1492 1492 traceback_t *traceback;
1493 1493 int i;
1494 1494
1495 +if (!tracemalloc_config.tracing) {
1496 +PUTS(fd, "Enable tracemalloc to get the memory block "
1497 +"allocation traceback\n\n");
1498 +return;
1499 + }
1500 +
1495 1501 traceback = tracemalloc_get_traceback(DEFAULT_DOMAIN, (uintptr_t)ptr);
1496 1502 if (traceback == NULL)
1497 1503 return;