load.c: report a refused irep from mrb_load_irep_cxt() - #7202
Conversation
`load_irep()` answers a `NULL` proc by raising `irep load error`, and `mrb_load_irep_buf_cxt()` and `mrb_load_irep_file_cxt()` both reach it that way. `mrb_load_irep_cxt()` returns before it instead, so a caller of `mrb_load_irep()` is handed `undef` with `mrb->exc` still clear and nothing to say why. It used to report. The early return was added in e55abd2 to skip allocating the temporary irep object when the read fails; before that, `NULL` went into `load_irep()` and raised there. Pass it there again, which is also what leaves the three of them the same shape.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 1 remains after this review. 📝 WalkthroughWalkthrough
ChangesIrep loading
Estimated code review effort: 2 (Simple) | ~5 minutes Merge Risk: ⚪ Minimal · up to This localized change makes refused irep loads report an error consistently instead of silently returning, improving test and embedder failure detection without introducing an actionable merge-blocking risk. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Three functions in
src/load.cturn a byte stream into a running proc, and all of them go throughload_irep(), which is where a refused irep is reported:Two of them hand it whatever the read returned:
mrb_load_irep_cxt()returns before it:so its caller gets
undefwithmrb->excstill clear.mrb_load_irep(), which every embedder reaches for and which the generated test drivers use, is that function with aNULLcontext.It used to report. The early return came in with e55abd2 (2020-11-24), to skip allocating the temporary irep object when the read fails; before that commit
NULLwent intoload_irep()and raised there:Passing
NULLintoload_irep()is what the other two already do, so the allocation the commit was avoiding is not reintroduced by it.What it costs to be silent
mrbgems/mruby-test/mrbgem.rakewrites onemrb_load_irep()per test file and checks the state after each:The check never fires, so a test file the VM cannot load is not a failure: it is subtracted from the run.
mrbtestcounts what it managed to load and reports 0 KO.On an
MRB_INT32build that is not hypothetical. Today's master cannot loadmrbgems/mruby-bigint/test/bigint.rbthere, and says so only if the file is fed tomruby -b, which reaches thebufsibling.rake testover the same build says nothing:With this commit the same build stops on it:
What made that irep unloadable is #7201, and with both applied the same build is green at 2313 tests, 0 KO. This commit is what would have made it a failure rather than 20 assertions quietly not run.
host-m32there is ani686-linux-gnu-gcccross toolchain with-m32andconf.gembox 'full-core', spelled out in #7201;build_config/host-m32.rbneeds a multilib gcc this machine has no-m32runtime for.Return value
undefbecomesnilon the failing path, which is whatmrb_load_irep_buf()andmrb_load_irep_file()already return there. Nothing in the tree reads the value of a failedmrb_load_irep(); the callers aremrbgems/mruby-test/driver.cand the driversmrbgem.rakegenerates, and all of them look atmrb->exc.include/mruby/irep.hdocuments no return value for the failing case.Tests
None.
mrb_load_irep()takes a pointer to a literal and no Ruby-visible path reaches it, so what this changes can only be seen from C or throughmrbtest's own drivers, which is the transcript above.Verification
rake -m testoverci/gcc-clang, every build green, 0 KO, 0 crash, no new warnings. The counts are master's to the test, since nothing here is reached unless a load fails.On an
MRB_INT32build the run stops, as above, until #7201 is applied; with both,host-m32(-m32, full-core) is 2313 tests, 0 KO, 4 skip, andhost-i32(-DMRB_INT32 -DMRB_NO_BOXING, full-core) is 2313 tests, 0 KO, 12 skip.Environment
Versions
g++forcxx_abiCompile lines for src/load.c
-MMD -c,-Iand-odropped.Summary by CodeRabbit