bug: resolve qualified class method calls without subroutine recursion

未關閉
#2,158 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
30/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
java, perl
領域
backend

研究方向

Start with the minimal reproducer in the body: run it on both the JVM and interpreter backends to confirm the Deep recursion and StackOverflowError. The bug is in how a fully qualified Class::Name->method invocant is resolved when a subroutine of the same name exists, so the parser or call-resolution code for class-method invocants is the place to look. Done means the reproducer prints Probe::Thing on both backends and existing direct-call and indirect-object tests still pass.

由索引模型根據 Issue 內容生成。

描述

area:parser bug

Summary

Data::ParseBinary v0.31 fails on PerlOnJava because its Struct helper recursively calls itself instead of invoking the Data::ParseBinary::Struct->create class method. The archived CPAN random-tester run 20261120-195805-13340 reports a StackOverflowError in t/01various.t; the system-Perl oracle passes all 275 tests.

The same reduced case fails on the current main launcher (build 2211d46023) on both the JVM and interpreter backends. System Perl passes it.

Root cause

A fully qualified class invocant is confused with a same-named fully qualified subroutine. In Data::ParseBinary, the helper Data::ParseBinary::Struct and the class package Data::ParseBinary::Struct share that name. Perl treats Data::ParseBinary::Struct->create(...) as a class method call. PerlOnJava routes the package token back to the existing Data::ParseBinary::Struct function, causing unbounded recursion.

The collision can be reduced without the CPAN distribution:

use strict;
use warnings;

package Probe;
sub Thing { return Probe::Thing->create(@_) }

package Probe::Thing;
sub create { return bless { name => $_[1] }, $_[0] }

package main;
my $thing = Probe::Thing();
print ref($thing), "\n";

Expected output under standard Perl:

Probe::Thing

PerlOnJava emits Deep recursion on subroutine "Probe::Thing" and then StackOverflowError on both backends. The stack repeats the Probe::Thing function at the Probe::Thing->create source line.

Control cases pass on PerlOnJava: using a scalar containing Probe::Thing as the method invocant, calling Probe::Thing::create(...) directly, and calling a static method on a package without a same-named subroutine. This isolates the failure to resolving the literal fully qualified class name when that name is also a callable subroutine.

CPAN evidence

  • Distribution: Data-ParseBinary v0.31 (pure Perl)
  • Run: 20261120-195805-13340
  • System Perl: all 275 tests pass
  • PerlOnJava: 4 of 5 test programs fail after t/01various.t hits StackOverflowError; the later parse errors are consequences of the missing TAP plans
  • Current main focused reproducer: JVM and interpreter both fail with the same recursion

Related issues

  • #1166 covers valid fully qualified indirect-constructor forms such as new HTTP::Response ...; it does not cover explicit Class::Name->method() syntax colliding with a same-named function.
  • #1222 tracks Perl-compatible deep-recursion warnings. This reproducer enters unintended recursion and overflows; it is a method-call resolution defect, not only a warning mismatch.

Acceptance criteria

  • The minimal reproducer prints Probe::Thing on both PerlOnJava backends without a recursion warning or stack overflow.
  • Existing direct subroutine and indirect-object parsing behavior remains intact.
  • Data-ParseBinary v0.31 passes its upstream suite on both PerlOnJava backends.
主要語言
Perl
星號
67
分支
8
平均合併
4 小時 36 分鐘
30 天內合併 PR
123

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

fglock/PerlOnJava 的其他 Issue

查看 fglock/PerlOnJava 的全部 Issue

相似的 Issue

更多 Perl Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。