Issue 19306: Warn unsuspecting readers that thread stacks are in reverse order (original) (raw)

Issue19306

Created on 2013-10-20 00:23 by gvanrossum, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
traceback.diff gvanrossum,2013-10-20 03:26 review
traceback2.diff gvanrossum,2013-10-20 23:41 review
Messages (8)
msg200527 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-10-20 00:23
I was confused for a while when seeing the thread stacks dumped by the faulthandler module. (See issue 19293.) I propose the following tweaks of the output to make this more obvious. The first chunk changes the header written when called as _Py_DumpTraceback(), the second change the per-thread headers printed by _Py_DumpTracebackThreads(). diff -r 02f6922e6a7e Python/traceback.c --- a/Python/traceback.c Sat Oct 19 17:04:25 2013 -0700 +++ b/Python/traceback.c Sat Oct 19 17:19:29 2013 -0700 @@ -603,7 +603,7 @@ unsigned int depth; if (write_header) - PUTS(fd, "Traceback (most recent call first):\n"); + PUTS(fd, "Stack (most recent call first):\n"); frame = _PyThreadState_GetFrame(tstate); if (frame == NULL) @@ -642,7 +642,7 @@ else PUTS(fd, "Thread 0x"); dump_hexadecimal(sizeof(long)*2, (unsigned long)tstate->thread_id, fd); - PUTS(fd, ":\n"); + PUTS(fd, " (most recent call first):\n"); } const char*
msg200537 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-10-20 03:26
BTW, another oddity in traceback.c: dump_hexadecimal() has the "int fd" argument at the end, while all other dump_*() functions have it at the front -- even its cousin dump_decimal(). Here's a patch that includes a fix.
msg200550 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-10-20 07:41
You must update unit tests in test_faulthandler.
msg200655 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-10-20 23:41
New patch, with fixed test. TBH now I'm getting worried that other programs may exist that parse this format and will get confused.
msg200660 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-10-21 00:03
> TBH now I'm getting worried that other programs may exist that parse this format and will get confused. A program parsing faulthandler output? Seriously? It would be nice, but I don't know any. Anyway, such program would probably use a regex to parse the output, and it's very easy to support Python 3.3 format and patched (future 3.4) format. > New patch, with fixed test. Thanks. The patch looks good to me, you can push it.
msg200678 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-21 01:21
New changeset cc8c37b5b449 by Guido van Rossum in branch 'default': Issue 19306: Add extra hints to faulthandler stack dumps that they are upside down. http://hg.python.org/cpython/rev/cc8c37b5b449
msg200685 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2013-10-21 02:18
On Victor's authority, committed. I've also (separately) committed some doc changes.
msg200712 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-10-21 08:00
Thanks. "(most recent call first)" was already present in some cases, but I forgot to mention it in all cases.
History
Date User Action Args
2022-04-11 14:57:52 admin set github: 63505
2013-10-21 08:00:25 vstinner set messages: +
2013-10-21 02🔞37 gvanrossum set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2013-10-21 01:21:11 python-dev set nosy: + python-devmessages: +
2013-10-21 00:03:38 vstinner set messages: +
2013-10-20 23:41:44 gvanrossum set files: + traceback2.diffmessages: +
2013-10-20 07:41:23 vstinner set messages: +
2013-10-20 03:26:56 gvanrossum set files: + traceback.diffkeywords: + patchmessages: +
2013-10-20 00:28:56 pitrou set assignee: pitrou -> vstinnernosy: + vstinner
2013-10-20 00:23:25 gvanrossum create