mruby-compiler: report a failed irep round trip in mrb_generate_code() - #7204
mruby-compiler: report a failed irep round trip in mrb_generate_code()#7204takumin wants to merge 1 commit into
mrb_generate_code()#7204Conversation
`parse_source()` writes a parse error to stderr and `codegen_error()` writes a codegen error there, both under the gate a caller that captures errors turns off. The dump and reload that turns the `mrc_irep` into an `mrb_irep` is the one compiler-side failure that takes neither: `mrb_generate_code()` returns `NULL` with nothing said. `mrb_load_exec()` answers that `NULL` by raising `ScriptError "codegen error"` and returning `undef`, but `mruby`, `mrb` and `mrdb` only print an exception when the value is not `undef`, which is how they keep from repeating what the compiler already printed. Nothing printed here, so the program ends at exit 1 without a word. Report both failures the way the two beside them are reported.
|
Warning Review limit reached
Next review available in: 3 minutes Limit details: You’ve used all 8 included reviews currently available under your plan. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
A program can end at exit 1 with nothing on either stream. On today's master,
build_config/default.rb, x86-64:65535 bytes of
aruns and prints 65535. 65536 is the boundary, and it says nothing about it.Where the report went
Two of the three ways compilation can fail write to stderr themselves, under a gate a caller that captures errors turns off.
parse_source():and
codegen_error():The third is the dump and reload that turns the
mrc_irepinto anmrb_irep, and it takes neither:mrb_load_exec()does answer thatNULL, by raisingScriptError "codegen error"and returningundef. What the front ends do with it is print it only when the value is notundef:which is 9bd17226d3, "Avoid duplicate message output (
SyntaxError,ScriptErroretc)":undefmeans the compiler already said it.mruby,mrbandmrdball carry that shape. Here the compiler said nothing, so nobody does.The exception is real, and a caller that reads exceptions rather than stderr has always seen it:
The change
mrb_generate_code()reports both failures through the samequiet_errorsgate as the two beside it, so every front end gets the line andevalkeeps getting only the exception:mrdbprints it too.mirbdoes not, and this does not change that: it setscapture_errorsso it can draw syntax errors itself with a caret, and answers aNULLfrommrb_generate_code()with a barecontinue. Giving it a line means routing this diagnostic through the parser's error buffer, which is a different change.What this does not fix
Why a 65536-byte string literal fails at all.
write_pool_block()records a pool string's length in auint16_t, and the only thing standing between a longer literal and a truncated record is an assertion that a release build compiles away:An
MRC_DEBUGbuild stops there instead, which isci/gcc-clang'sfull-debugon the same file:That is a separate defect and wants a separate fix. It is used here because it is the shortest program that reaches this code path on a stock build.
#7201 is the other way in that turned up this week: on an
MRB_INT32build every integer literal from2**31to2**63 - 1was refused by the loader, andmruby -e 'p 1<<31'was silent for the reason above. With this commit and without #7201, that build answers:Two unrelated defects, both invisible at the same place.
Tests
None.
mrb_generate_code()reaches this only when a dump and its reload disagree, which is a defect wherever it happens rather than something a test can ask for and keep. Pinning it to the 65536-byte literal would pin a test to the defect above staying unfixed.Verification
rake -m testoverci/gcc-clang, every build green, 0 KO, 0 crash, no new warnings, and the counts are master's to the test.MRB_NO_STDIOcompiles the file with the report gone, warning free, checked on aMRuby::CrossBuildcarryingmruby-compilerandmruby-eval(build_config/minimal.rbbuilds no gem, so it does not compile this file).Environment
Versions
g++forcxx_abiCompile lines for mruby_compat.c
-MMD -c,-Iand-odropped.