Repository navigation
CmiAbort: print the reason at its full length (#287) - #301
Conversation
CmiAbort formatted its reason into a 256-byte stack buffer, so any reason longer than 255 characters was cut off. Format it in two passes: measure with vsnprintf(NULL, 0, ...), use a 1024-byte stack buffer when it fits, and malloc a buffer of the measured size otherwise. The rest of the abort path is unchanged. tests/abort_message aborts with a 600-character reason and checks that the last 60-character chunk, which starts at column 541, is printed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Charm++ on this reconverse (advisory): Charm++ (recharm) builds and its reconverse test tier passes against this tree. |
|
i don't know if i agree with this. What good reason is there for an abort message longer than 256 characters? |
Truncating the message to an arbitrary length is an unnecessary footgun. If an abort needs to tell the user something, it should be able to say whatever it needs. |
ritvikrao
left a comment
There was a problem hiding this comment.
ok, i guess an arbitrary limit is not a good idea
|
The cap is on CmiAbort, so it applies to every CkAbort an application writes, not just to the runtime's own messages. Application abort strings carry file paths, hostnames, configuration dumps and LCI error text, and 255 characters silently drop the tail, which is where the specific value is. The fix costs a 1 KiB stack buffer on the normal path and a heap allocation only beyond that, and the test pins it. I would rather not have a length rule for error messages at all. |
Fixes #287. CmiAbort formatted its reason into a 256-byte stack buffer, so anything past 255 characters was cut. It now measures the formatted length first, uses a 1 KiB stack buffer for the common case and a heap buffer beyond that (never freed: abort() follows), and prints the whole reason. The rest of the abort path (CmiAbortHelper, the stack trace, SIGABRT reset, abort) is unchanged.
tests/abort_message aborts with a 600-character reason and checks that the last chunk, at column 541, is printed; it fails on the old code.
Tested on macOS arm64: full ctest passes (standalone_project excepted, the known macOS failure).
🤖 Generated with Claude Code