Skip to content

fix: Hash::MultiValue + blib/arch — splice spill, deref slice, dclone hooks#478

Open
fglock wants to merge 2 commits intomasterfrom
fix/hash-multivalue-dclone-splice
Open

fix: Hash::MultiValue + blib/arch — splice spill, deref slice, dclone hooks#478
fglock wants to merge 2 commits intomasterfrom
fix/hash-multivalue-dclone-splice

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 9, 2026

Summary

Fixes all ./jcpan -t Hash::MultiValue test failures (was 7/10 programs passing, now 10/10) and the ./jcpan -t HTTP::Thin blib/arch issue.

Bug 1: JVM backend — splice with constant sub causes ASM frame crash

  • handleSpliceBuiltin left the first arg on the JVM operand stack while evaluating remaining args
  • When those contained a function call (e.g. constant sub C from use constant), the blockDispatcher GOTOs created inconsistent stack depths at merge points, crashing ASM Frame.merge
  • Fix: Register spilling in EmitOperator.java, matching the existing handlePushOperator pattern

Bug 2: Interpreter backend — @$ref[@idx] = ... unsupported

  • The array slice assignment handler in CompileAssignment.java only supported @array[@idx] with plain IdentifierNode
  • Fix: Added a branch to handle dereferenced array refs using DEREF_ARRAY/DEREF_ARRAY_NONSTRICT opcodes

Bug 3: Storable::dclone — shared refs from STORABLE_freeze hooks

  • dclone passed extra refs from STORABLE_freeze directly to STORABLE_thaw without cloning them
  • Inside-out objects like Hash::MultiValue ended up sharing internal arrays between original and clone
  • Fix: Deep-clone extra refs (indices 1+) before passing to STORABLE_thaw in Storable.java

Bug 4: blib/arch missing in generated Makefile

  • ExtUtils::MakeMaker generated a Makefile whose pure_all target never created blib/arch/
  • blib.pm requires it and dies if missing
  • Fix: Added @mkdir -p blib/arch to the pure_all target in ExtUtils/MakeMaker.pm

Test plan

  • make passes (all unit tests)
  • ./jcpan -t Hash::MultiValue — 10/10 test programs, 55/55 subtests PASS
  • ./jcpan -t HTTP::Thin — blib/arch created correctly

Generated with Devin

fglock and others added 2 commits April 9, 2026 23:12
…ne hooks

Three bugs fixed:

1. JVM backend: splice with constant sub causes ASM frame crash
   handleSpliceBuiltin left the first arg on the JVM operand stack
   while evaluating remaining args. When those contained a function
   call (constant sub), the blockDispatcher's GOTOs created
   inconsistent stack depths at merge points. Fixed with register
   spilling, matching handlePushOperator's existing pattern.

2. Interpreter backend: @$ref[@idx] = ... unsupported
   The array slice assignment handler only supported @array[@idx]
   with plain IdentifierNode. Added a branch to handle dereferenced
   array refs using DEREF_ARRAY/DEREF_ARRAY_NONSTRICT opcodes.

3. Storable::dclone: shared refs from STORABLE_freeze hooks
   dclone passed extra refs from STORABLE_freeze directly to
   STORABLE_thaw without cloning them. Inside-out objects like
   Hash::MultiValue ended up sharing internal arrays between
   original and clone. Fixed by deep-cloning extra refs (indices 1+).

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The generated Makefile pure_all target only created blib/lib/
but not blib/arch/. The blib.pm pragma requires both directories
to exist (-d blib && -d blib/lib && -d blib/arch), so use blib
and -Mblib would die with Cannot find blib even in ...

This caused CPAN module test suites (e.g. HTTP::Thin) to fail when
they use open3 with -Mblib to verify modules load cleanly.

Add mkdir -p blib/arch to the pure_all target so the directory
always exists alongside blib/lib.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

1 participant