Repository navigation
Description
Summary
l1a's ItemFactory still goes out of balance while compiling gnu.java.lang.VMClassHelper#getPackagePortion and sun.reflect.ReflectionFactory#newMethod, so X86BytecodeVisitor.endMethod() logs "Unbalanced item handling" and repairs by calling ifac.balance().
Steps to Reproduce
- Java CI: run
45058380234, job137319309715(boot32), step "Run QEMU Boot Test (32-bit)" - Or locally:
sh build.sh cd-x86-lite, then
qemu-system-x86_64 -cdrom all/build/cdroms/jnode-x86-lite.iso -m 1024 -M pc -cpu pentium -boot once=d,menu=off -net none -serial file:/tmp/com1.txt -display none - Wait for the serial log to reach
System has finished(it does), then:
grep "Unbalanced item handling" /tmp/com1.txt
Buggy Outcome
Boot succeeds, but two WARN lines appear:
WARN Unbalanced item handling in gnu.java.lang.VMClassHelper#getPackagePortion!(Ljava/lang/String;)Ljava/lang/String; (leaked 12 item(s))
WARN Unbalanced item handling in sun.reflect.ReflectionFactory#newMethod!(...(Ljava/lang/reflect/Method; (leaked -12 item(s))
Emitter: core/src/core/org/jnode/vm/x86/compiler/l1a/X86BytecodeVisitor.java:675-682, in endMethod(), guarded by ItemFactory.CHECK_BALANCED_ITEM_FACTORY (ItemFactory.java:34, hardcoded true). endMethod() currently repairs with ifac.balance().
Frequency over the last 5 Java CI runs of boot32 (intermittent, not a regression of the commits named):
| run | head | warning |
|---|---|---|
| 45017224678 | 92bc62e | yes (2 lines) |
| 45025012042 | 55e824a | yes (2 lines) |
| 45020808359 | 3cc547f | no |
| 45054987606 | a600fd2 | yes (2 lines) |
| 45058380234 | 3bf9ef5 | yes (2 lines) |
Note the two numbers: +12 then -12. The item factory is a per-thread reused object across methods, so the second method releases items the first method acquired: an acquire/release pair is not unwound on one of the paths those two methods exercise, and the imbalance only evens out by accident across the pair.
Expected Outcome
The compiler's item accounting is exact, so a clean 32-bit boot emits no "Unbalanced item handling" line at all, and no method has to rely on another method's opposite drift.
Context for why this is still open rather than a duplicate:
052913944e53e..."fix(vm): recover l1a compiler state after failed compilation (VM Level1A compiler: 'Register(s) in use' Error at X86RegisterPool.reset during boot-time Main invocation #614)" converted the fatalError: Register(s) in useatX86RegisterPool.resetinto a warning plus force-reset, so the boot survives. That is the recovery half.- L1A compiler: investigate 'unbalanced item handling' warnings during boot #618 (closed, PR Fix L1A constant-folding item leaks #625 merged as
1543fe90, "Fix L1A constant-folding item leaks") fixed the drift forBootInfos.scanManifestResourceandBundleLauncherService.launch, and touched only the constant-folding path inItemFactory(+4) andX86BytecodeVisitor(+5/-1). A different method pair still drifts, so the accounting defect is wider than constant folding.
Test Coverage Basis
- Existing:
core/src/test/org/jnode/vm/x86/compiler/l1a/X86Level1ACompilerVisitorTest.javacovers the release/cleanup path (from Fix L1A visitor CCE, tests green, ISO builds #744), andX86RegisterPoolTestfrom VM Level1A compiler: 'Register(s) in use' Error at X86RegisterPool.reset during boot-time Main invocation #614 covers reset vs forceReset. - Gap: nothing asserts the item factory is balanced after compiling the affected methods, so the drift never fails a test and only shows up in a boot log.
- Proposed: host-JVM test in
core/src/test/org/jnode/vm/x86/compiler/l1a/that compilesVMClassHelper.getPackagePortionandsun.reflect.ReflectionFactory.newMethodthrough l1a (that path is already reachable from a host test, per Fix L1A visitor CCE, tests green, ISO builds #744) and assertsItemFactoryis balanced after each method. The fix must make that test pass.
Explicit Constraints
- Keep
ItemFactory.CHECK_BALANCED_ITEM_FACTORYand keep theendMethod()warning. Do not silence this by disabling the check or deleting the warning. - Do not "fix" it by calling
ifac.balance()earlier, more often, or on more paths. The accounting has to be exact on its own. - Java-side only. No changes under
core/src/native/x86/, and no config/plugin-list touch.
Environment
- Commit:
3bf9ef50d(warning also seen on92bc62e7,55e824a7,a600fd2e) - Host JDK: 8 in Java CI; local host 11 (build needs 1.6/1.7/1.8)
- Build target:
cd-x86-lite - Bitness: 32-bit
- Run: QEMU (command above) / GitHub Actions job 137319309715
- ISO:
all/build/cdroms/jnode-x86-lite.iso - Boot reached
System has finished: yes
Triage Addendum (auto, 2026-11-23)
- Area / Kind: area/vm / kind/bug
- Blast radius: L5 system (l1a/l1b JIT item accounting reaches every L1a-compiled method and the boot path; QEMU boot proof required)
- Expected scope:
core/src/core/org/jnode/vm/x86/compiler/l1a/ItemFactory.javaandX86BytecodeVisitor.java(plus l1b emitters if the leak is emission-side), ~20-100 lines, fixing acquire/release symmetry. No-go:CHECK_BALANCED_ITEM_FACTORY, theendMethod()warning, extraifac.balance()calls,core/src/native/x86/, config/plugin-list files - Test path:
sh build.sh -f core/build-tests.xml all-junitwith a new host test asserting the factory is balanced per compiled method incore/src/test/org/jnode/vm/x86/compiler/l1a/; plus 32-bitsh build.sh cd-x86-liteQEMU boot with zero "Unbalanced item handling" lines - Merge signal: human-review (kind/bug on boot-critical JIT accounting)
- Gaps: none blocking; L1A compiler: investigate 'unbalanced item handling' warnings during boot #618 fixed only the constant-folding pair, so this is a follow-up with a different trigger pair
- Full report:
## Triagecomment below.
✅ Ticket Runner Status
| Field | Value |
|---|---|
| Phase | DONE |
| Turn | 3/7 |
| Retries | 0/3 |
| PR | #987 |
| Review in progress | no |
| Started | 2026-11-23T18:16:51.686Z |
Activity
LSantha commentedon Nov 23, 2026
/oc triage issue #986
Triage run ONLY. Load the jnode-triage-issue skill and obey it. Output is exactly one ## Triage comment plus kind/area label edits. FORBIDDEN in this run: git checkout -b, git push, gh pr create, any branch, any PR.
LSantha commentedon Nov 23, 2026
Triage
org/jnode/vm/x86/compiler/l1a, L1a JIT item accounting)sh build.sh cd-x86-lite→qemu-system-x86_64 -cdrom all/build/cdroms/jnode-x86-lite.iso -m 1024 -M pc -cpu pentium -boot once=d,menu=off -net none -serial file:/tmp/com1.txt -display none→grep "Unbalanced item handling" /tmp/com1.txt; actual: two WARNs (+12VMClassHelper#getPackagePortion, -12sun.reflect.ReflectionFactory#newMethod), expected: nonecore/src/core/org/jnode/vm/x86/compiler/l1a/ItemFactory.javaandX86BytecodeVisitor.java(plus l1b emitters if the leak is emission-side), ~20-100 lines fixing acquire/release symmetry. No-go:CHECK_BALANCED_ITEM_FACTORY, theendMethod()warning, extraifac.balance()calls,core/src/native/x86/, config/plugin-list filessh build.sh -f core/build-tests.xml all-junitwith a new host test asserting the factory is balanced per compiled method incore/src/test/org/jnode/vm/x86/compiler/l1a/; plus 32-bitsh build.sh cd-x86-liteQEMU boot with zeroUnbalanced item handlinglinesgithub run
LSantha commentedon Nov 23, 2026
/oc Please proceed with this task.
LSantha commentedon Nov 23, 2026
/oc Please proceed with this task.
LSantha commentedon Nov 23, 2026
Created PR #987
github run