Skip to content

Fix Math-BigInt chained temporaries and arithmetic#709

Open
fglock wants to merge 13 commits into
masterfrom
fix/math-bigint-method-chain-regression
Open

Fix Math-BigInt chained temporaries and arithmetic#709
fglock wants to merge 13 commits into
masterfrom
fix/math-bigint-method-chain-regression

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented May 11, 2026

Summary

  • Fix localized global restore so foreach aliasing of localized $_ cannot corrupt method-chain temporaries.
  • Invalidate bless-id overload classification with method/MRO cache invalidation so Math::BigInt::Calc picks up inherited overloads after @isa is populated.
  • Add focused Math-BigInt regression coverage for bexp chaining, inherited overload classification, bmul, bmuladd, and bmodpow.

Tests

  • timeout 1200 make > /tmp/make-math-bigint-pr.log 2>&1; printf EXIT line appended; EXIT: 0
  • All 49 src/test/resources/module/Math-BigInt/t/*.t via timeout 300 jperl per file; all EXIT: 0

Notes

  • Full bundled-module verification still has YAML-only failures in this workspace; YAML is being investigated separately in ../PerlOnJava3/.

@fglock
Copy link
Copy Markdown
Owner Author

fglock commented May 11, 2026

Updated this PR to include PR #710 for combined testing.

Included commits:

Current verification before push:

  • make passed: /tmp/make-pr709-with-yaml-2.log, EXIT: 0
  • make test-bundled-modules is/was running in /tmp/test-bundled-modules-pr709-with-yaml.log; I will post the final result when it completes.

@fglock
Copy link
Copy Markdown
Owner Author

fglock commented May 11, 2026

Combined verification result after including PR #710:

  • make passed: /tmp/make-pr709-with-yaml-2.log, EXIT: 0
  • make test-bundled-modules ran on commit 8fe7d2d: /tmp/test-bundled-modules-pr709-with-yaml.log, EXIT: 2
  • YAML failures are gone.
  • Math-BigInt failures are gone.
  • Remaining bundled-module failure: module/Unicode-Collate/t/illegal.t, reported at line 61 as not ok 60.

Focused check:

  • jperl direct run of Unicode-Collate/t/illegal.t produces not ok 60 and not ok 63 but exits 0: /tmp/unicode_collate_illegal_pr709.log
  • system perl direct run passes all 176 assertions: /tmp/unicode_collate_illegal_system.log

@fglock fglock force-pushed the fix/math-bigint-method-chain-regression branch from 8fe7d2d to 1f4b7b9 Compare May 11, 2026 15:52
@fglock
Copy link
Copy Markdown
Owner Author

fglock commented May 11, 2026

Update after rebasing and force-with-lease pushing PR #709 to 1f4b7b9.

Included the PR #710 YAML commits on this branch:

  • c9d1097 fix: resolve bareword and special variable parsing issues in YAML/Mo.pm
  • dfaaa09 fix: keep qualified underscore identifiers packageable

Additional fixes in the latest commit:

  • Preserve explicit surrogate Perl scalars so Unicode-Collate illegal.t no longer collapses adjacent surrogate scalars into one Java supplementary code point.
  • Restore defined main-package ::sub calls while keeping missing ::bareword fallback, which removes the leading-:: 0/0 core-test regressions from the YAML merge.

Verification after rebase:

  • make: PASS (/tmp/make-pr709-after-rebase-surrogate-leading-colon.log)
  • Math-BigInt predicate: PASS (/tmp/math_bigint_predicate_after_rebase.log)
  • module/Unicode-Collate/t/illegal.t: PASS (/tmp/unicode_collate_illegal_after_rebase.log)
  • make test-bundled-modules: PASS (/tmp/test-bundled-modules-pr709-after-rebase-final.log)

Log compare for PR7027 vs PR709:

  • The large reported regression is dominated by regex tests recorded as 0/0 in the external PR709 log. out.json shows ClassNotFoundException: org.perlonjava.app.cli.Main for those entries.
  • A local regex slice on the rebased branch ran normally: re/reg_nocapture.t 25/25, re/qr.t 4/4, re/pos.t 7/8, so the regex 0/0 block appears to be an invalid external test run artifact.
  • The remaining non-0/0 one-test drops reproduce at the PR709 after-counts locally: comp/package.t 12/14, japh/abigail.t 103/130, op/tr.t 279/318, uni/package.t 15/18. Direct logs are in /tmp/pr709-*-direct.log.

GitHub CI restarted from the new pushed head and is currently running.

@fglock
Copy link
Copy Markdown
Owner Author

fglock commented May 11, 2026

Updated PR #709 with commit 671beeab2.

The four non-0/0 compare regressions are restored against the PR7027 baseline:

comp/package.t      13/14
japh/abigail.t     104/130
op/tr.t            280/318
uni/package.t       18/18

Additional verification:

make                                      PASS  (/tmp/make-pr709-core-deltas-fix3.log)
make test-bundled-modules                 PASS  (/tmp/test-bundled-modules-pr709-core-deltas-fix.log)
Unicode-Collate t/illegal.t               PASS  (/tmp/unicode_collate_illegal_pr709_core_deltas.log)
Math::BigInt bexp predicate               PASS  output: 2
CLI -s after -- predicate                 PASS  output: Just another Perl Hacker

The focused four-file rerun log is /tmp/pr709-four-deltas-after-fix1.log.

@fglock
Copy link
Copy Markdown
Owner Author

fglock commented May 11, 2026

Updated PR #709 with the DBIx::Class leak-tracer reproducer and the tail-call alias cleanup fix.

Verification run locally:

  • make -> passed (/tmp/make-dbic-final-unit.log, exit 0)
  • Math::BigInt bexp predicate -> passed (2, exit 0)
  • New unit unit/refcount/dbic_leak_tracer_compose_namespace.t is included in make and passes
  • Existing tail-call cleanup units pass in make

I also reran DBIx::Class t/52leaks.t. The original detached result source failure is gone; the run now reaches ok 4 and auto-checks 5 weak refs cleanly, then exits 255 because the earlier nested txn exception resurfaces during later cleanup (/tmp/dbic_52leaks_after_reproducer_fix.log). That looks like a separate exception/eval cleanup issue from the detached source regression.

fglock and others added 12 commits May 12, 2026 14:50
Keep localized global restore cleanup scoped to the scalar installed by local().
This prevents foreach aliasing of localized $_ from corrupting method-chain temporaries.

Invalidate bless-id overload classification when method and MRO caches are invalidated.
This lets Math::BigInt::Calc inherit overloads after @isa is populated, keeping large arithmetic operands distinct.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
- Prevent special variables ($_, $/, $\, etc.) from being package-qualified in IdentifierParser
  When a bareword :: separator follows a single-letter special variable, treat it as a separate
  bareword string rather than continuing to parse as part of the variable name

- Fix ::identifier bareword handling in ParsePrimary
  Only treat ::identifier as a function call if it has explicit parentheses (::foo()).
  All other ::identifier patterns are now treated as bareword strings.
  This ensures barewords in expression contexts like &{$_::e} remain as strings, not function calls.

- Exclude JAR signature files from Maven shade plugin
  Prevents "Invalid signature file digest for Manifest main attributes" errors when
  rebuilding with shaded dependencies

Fixes YAML test suite - now passes all 482/482 tests and 54/54 programs

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
After merging the YAML parser fix, preserve first-token tracking across package separators so qualified names such as DBD::_::common::ISA still parse while first-token special variables like $_ remain unqualified.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Keep explicit surrogate code points out of raw Java UTF-16 so adjacent Perl surrogate scalars cannot collapse into one supplementary Java code point. This fixes Unicode::Collate match length handling in illegal.t.

Restore Perl leading ::sub behavior for existing main-package subs while preserving bareword fallback when the sub is missing. This removes the 0/0 core-test regressions introduced by the YAML parser merge.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Restore the four non-0/0 core-test deltas reported for PR709:
- keep stash anonymization visible after method-cache invalidation
- vivify implicit BEGIN globs for use/no declarations
- emit the tr///r void-context warning
- parse -s switches after -- for -e programs

Add focused unit coverage for the engine-side regressions and Java coverage
for the command-line -s parser case.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Track owned inserts into aliased argument arrays so goto &sub cleanup releases only the temporaries inserted by the trampoline, not caller-owned aliases. Add a DBIx::Class t/52leaks-style reproducer for the global bless leak tracer.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: OpenAI Codex <codex@openai.com>
Generated with Codex (https://openai.com/codex)

Co-Authored-By: OpenAI Codex <codex@openai.com>
Preserve in-flight assignment temporaries during weak-ref sweeps and stop
using stale scalar-registry entries as live roots. When Scalar::Util::isweak
observes DBIC-style DESTROY-rescued objects, run the full two-pass weak-ref
sweep while returning the pre-sweep weak status so leak-tracer registry checks
see normal weak collection instead of a corrupted slot.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Use an explicit superclass clone call in the DBIC leak tracer regression test so it passes in the CI unit runner, where @inc only contains the bundled Perl library and jar PERL5LIB.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Register bytecode-interpreter lexical variables with MyVarCleanupStack so weak-ref sweeps see live my scalars, hashes, and arrays the same way the JVM backend does. This prevents DBIC schema/storage weak backrefs from being cleared while a top-level my $schema is still in scope.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Align assignment-style undef with direct undef cleanup for DBIC-style
DESTROY rescue, but only for the specific object rescued by that undef.
This lets HandleError callbacks see that the schema/storage owner is gone
without draining other live rescued schemas.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
@fglock fglock force-pushed the fix/math-bigint-method-chain-regression branch from 12ec041 to 5d7cb81 Compare May 12, 2026 12:54
Record the t/52leaks.t baseline and cache design for PR #709 before implementing the runtime change.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.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