Repository navigation
charmxi: do not crash on serial blocks when run without -orig-file - #4027
Merged
Merged
Conversation
processAst left cur_file NULL when charmxi was invoked without -orig-file (charmc always passes it; direct callers usually do not), and the serial construct wrote that pointer into a #line directive, so any non-empty serial block crashed the translator. Fall back to the input file name, as the preprocessing path already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lvkale
force-pushed
the
charmxi-origfile-null
branch
from
October 10, 2026 23:59
abe1f86 to
76787b6
Compare
ritvikrao
approved these changes
Oct 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause
processAstinsrc/xlat-i/xi-main.Csetcur_file = origFile = origFile_;.origFile_is NULL unless charmxi is given-orig-file. charmc always passes that flag, but direct callers of charmxi usually do not.SerialConstruct::generateCode(src/xlat-i/sdag/constructs/Serial.C) writescur_fileinto a#linedirective throughXStr::append(const char*), which callsstrlenon the NULL pointer. As a result, any non-emptyserialblock made charmxi segfault. The other users ofcur_fileprint it in diagnostics: the SDAG-constructor error inSdagEntry.Cand the error reporters inxi-util.C. They also crashed instead of reporting the error.Fix
When no
-orig-fileis given,cur_filefalls back to the input file name, or toSTDINwhen charmxi reads standard input.readFilealready uses the same fallback while parsing.origFileitself is unchanged.Reproducer
charmxi t.cit.def.hhas#line 5 "t.ci"charmxi < t.cicharmxi -orig-file t.ci t.ci#line 5 "t.ci"Regression test
tests/charm++/charmxi_parsinggainsSerialNoOrigFile.ciand atest-charmxi-directtarget, which is part ofmake test. The target runsbin/charmxidirectly on that file without-orig-fileand checks that the generated.def.hhas a#linedirective naming the.cifile. With the unfixed charmxi the target fails with a segmentation fault.🤖 Generated with Claude Code