Skip to content

feat: PerlRuntime multiplicity with regex timeout fix#488

Closed
fglock wants to merge 2 commits intomasterfrom
feature/multiplicity-v2
Closed

feat: PerlRuntime multiplicity with regex timeout fix#488
fglock wants to merge 2 commits intomasterfrom
feature/multiplicity-v2

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 11, 2026

Summary

Re-applies the multiplicity regression fixes on top of the reverted master (PR #487). Rebased cleanly onto current master.

Changes

Commit 1: fix: bind PerlRuntime to regex timeout thread pool workers

  • Binds PerlRuntime ThreadLocal to regex timeout executor threads (RuntimeRegex.java)
  • Note: PerlRuntime binding was removed during rebase since PerlRuntime class doesn't exist on master post-revert

Commit 2: fix: resolve multiplicity regressions in eval STRING JVM compilation

  • JvmClosureTemplate: Re-adds the JVM closure template class for eval STRING JVM compilation path
  • BytecodeCompiler: Adds JVM compilation attempt for anonymous subs in eval STRING, with fallback to interpreter. Skips JVM for closures with non-scalar captures (@/% variables). Catches LinkageError (VerifyError) in addition to Exception
  • OpcodeHandlerExtended: Handles both JvmClosureTemplate and InterpretedCode in CREATE_CLOSURE opcode, with proper attribute dispatch for JVM closures
  • InterpretedCode: Defensive copy of attributes in withCapturedVars()

Test Results

Test Baseline (master) This Branch
alarm.t 5/5 5/5
goto-sub.t 32/44 32/44
attrs.t 153/159 158/159 (+5)
parser.t 120/185 121/185 (+1)

All unit test shards pass (make succeeds).

Test plan

  • make passes (BUILD SUCCESSFUL, all unit shards)
  • alarm.t: 5/5 passing
  • goto-sub.t: 32/44 (matches baseline)
  • attrs.t: 158/159 (+5 over baseline)
  • parser.t: 121/185 (+1 over baseline)

Generated with Devin

matchRegexWithTimeout() creates a single-thread executor for
alarm-based regex timeout. After the multiplicity migration, these
worker threads have no PerlRuntime bound, causing
"No PerlRuntime bound to current thread" errors when
matchRegexDirect() accesses per-runtime regex state.

This broke jcpan version parsing because CPAN::Module::parse_version
sets alarm() before calling MM->parse_version(), which triggers
regex matching in a timeout thread.

Fix: capture PerlRuntime.current() before submitting to the executor
and bind it in the worker thread via PerlRuntime.setCurrent().

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock force-pushed the feature/multiplicity-v2 branch from 86971e2 to 7c925ee Compare April 11, 2026 09:48
- Fix alarm: bind PerlRuntime to alarm scheduler thread so %SIG
  is accessible (alarm.t tests 1-4)
- Fix goto-sub.t: skip JVM compilation for closures capturing
  non-scalar variables (@arrays, %hashes) since the interpreter
  stores them as RuntimeBase but JVM expects typed parameters
- Fix parser.t: catch LinkageError (VerifyError) in addition to
  Exception when JVM bytecode verification fails for eval STRING
  anonymous subs, allowing proper fallback to interpreter
- Fix attrs.t: propagate attributes through JvmClosureTemplate
  for JVM-compiled closures, and make defensive copies of
  attribute lists to prevent shared-reference mutation bugs
- Add attributes field to JvmClosureTemplate and dispatch
  MODIFY_CODE_ATTRIBUTES for JVM closures in CREATE_CLOSURE handler

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock force-pushed the feature/multiplicity-v2 branch from 7c925ee to f98ce32 Compare April 11, 2026 10:41
@fglock fglock closed this Apr 11, 2026
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