Skip to content

Fix Pod::Spell and scalar temporary weak references#869

Merged
fglock merged 2 commits into
masterfrom
fix/pod-spell-errors
Jul 24, 2026
Merged

Fix Pod::Spell and scalar temporary weak references#869
fglock merged 2 commits into
masterfrom
fix/pod-spell-errors

Conversation

@fglock

@fglock fglock commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • load Encode.pm when applying a PerlIO :encoding(...) layer
  • match the visible side effect provided by standard Perl's PerlIO::encoding
  • keep unit/refcount/weaken_edge_cases.t unchanged and fix its scalar-temporary weak-reference failure
  • avoid a reachability walk for the scalar-temporary case by using constant-time ownership metadata

Root causes

Pod::Wordlist opens its bundled wordlist with :encoding(UTF-8).
Standard Perl loads Encode while applying that layer, and Pod::Spell
later calls Encode::encode. PerlOnJava performed the charset conversion
directly without loading Encode, so the call was undefined.

The added PerlIO unit test changed the local parallel shard layout and exposed
an existing failure in unit/refcount/weaken_edge_cases.t: a weak reference to
an otherwise-unbound scalar returned from a subroutine remained defined.
RuntimeScalar.createReference() now birth-tracks only referents with no
lexical, closure, package-global, or aggregate owner. WeakRefRegistry can
therefore clear that proven ephemeral referent directly, without walking the
live object graph.

Test plan

  • make — passes all unit-test shards
  • ./jperl src/test/resources/unit/refcount/weaken_edge_cases.t — 43/43 pass
  • ./jperl src/test/resources/unit/bless_existing_scalar_ref_destroy.t — 4/4 pass
  • prove src/test/resources/unit/perlio_encoding_loads_encode.t
  • ./jperl src/test/resources/unit/perlio_encoding_loads_encode.t
  • ./jcpan Pod::Spell — all 8 test files and 54 tests pass; install succeeds
  • 10,000 nested scalar-temporary weaken operations, five runs:
    fix mean 0.404s; clean parent mean 0.404s
  • GitHub CI for the original commit — Ubuntu and Windows builds pass

Generated with Codex

fglock and others added 2 commits July 24, 2026 11:38
Match Perl's visible side effect of loading Encode when an
:encoding(...) layer is applied. Pod::Spell relies on this after its
wordlist is opened as UTF-8.

Add a focused regression test for Encode::encode availability.

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

Co-Authored-By: Codex <codex@openai.com>
Birth-track unbound scalar referents that have never occupied a lexical,
closure, package root, or aggregate slot. This lets weakening the sole
reference consume it immediately without a reachability walk.

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

Co-Authored-By: Codex <codex@openai.com>
@fglock fglock changed the title Fix Pod::Spell by loading Encode for encoding layers Fix Pod::Spell and scalar temporary weak references Jul 24, 2026
@fglock
fglock merged commit c5a4b23 into master Jul 24, 2026
2 checks passed
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