Skip to content

CmiAbort: print the reason at its full length (#287) - #301

Merged
ritvikrao merged 3 commits into
mainfrom
abort-message-length
Oct 22, 2026
Merged

ritvikrao merged 3 commits into
mainfrom
abort-message-length

Conversation

@lvkale

@lvkale lvkale commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

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

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>
@lvkale
lvkale requested a review from ritvikrao October 22, 2026 12:36
@github-actions

Copy link
Copy Markdown

Charm++ on this reconverse (advisory): Charm++ (recharm) builds and its reconverse test tier passes against this tree.

ritvikrao
ritvikrao previously approved these changes Oct 22, 2026
@ritvikrao
ritvikrao dismissed their stale review October 22, 2026 16:00

need to check if this is needed

@ritvikrao

Copy link
Copy Markdown
Collaborator

i don't know if i agree with this. What good reason is there for an abort message longer than 256 characters?

@evan-charmworks

Copy link
Copy Markdown

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 ritvikrao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i guess an arbitrary limit is not a good idea

@lvkale

lvkale commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

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.

@ritvikrao
ritvikrao merged commit 210f45e into main Oct 22, 2026
5 checks passed
@ritvikrao
ritvikrao deleted the abort-message-length branch October 22, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CmiAbort truncates the reason to 255 characters (char newmsg[256])

3 participants