Hi Jerry,
On 2007-09-11, at 14:34:30 -0400, Jerry D. Hedden via RT wrote:
Show quoted text> 'perl ppport.h' erroneously reports that Perl_croak_nocontext needs aTHX_:
>
> === Analyzing ./shared.xs ===
> *** Doesn't pass interpreter argument aTHX to Perl_croak_nocontext
>
> When I modify ppport.h to remove the 'v' for croak_nocontext, I get:
>
> === Analyzing ./shared.xs ===
> *** Uses Perl_croak_nocontext instead of croak_nocontext
>
> If I then make this change, it won't compile:
>
> shared.o:shared.c:(.text+0xc39): undefined reference to `_croak_nocontext'
> shared.o:shared.c:(.text+0x4c9d): undefined reference to `_croak_nocontext'
> collect2: ld returned 1 exit status
>
> The following change to ppport.h seems to fix all this:
>
> --- ppport.h
> +++ ppport.h
> @@ -703,6 +703,7 @@
> PerlIO_tell||5.007003|
> PerlIO_unread||5.007003|
> PerlIO_write||5.007003|
> +Perl_croak_nocontext|||n
> Perl_signbit||5.009005|n
> Perl_warner_nocontext|5.006000||p
> Perl_warner|5.006000||p
> @@ -1096,7 +1097,6 @@
> cop_free|||
> cr_textfilter|||
> create_eval_scope|||
> -croak_nocontext|||vn
> croak|||v
> csighandler||5.009003|n
> curmad|||
>
> Sorry, but I don't now what to patch in Devel::PPPort to fix this.
Thanks for your report!
Indeed, this is clearly a bug in Devel::PPPort. However, it's not in the
API specification. The problem is that while the "n" flag (meaning: this
function doesn't take an aTHX) is obviously present for croak_nocontext()
and all other _nocontext() functions, that information is never used
within ppport.h. My best guess is that I wanted to implement it (hence
the presence of the "n" flag), but just didn't do it.
The fix is actually pretty trivial:
mhx@r2d2 ~/src/perl/Devel-PPPort/Current $ wdiff -bu parts/inc/ppphbin
==========================================================================
/parts/inc/ppphbin[/Devel-PPPort/Current(44)] < > parts/inc/ppphbin
--- ppphbin[/Devel-PPPort/Current(44)]
+++ ppphbin (local file)
@@ -387,4 +387,5 @@
for $func (sort keys %{$file{uses_Perl}}) {
if ($API{$func}{varargs}) {
+ unless ($API{$func}{nothxarg}) {
my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))}
{ $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge);
@@ -392,4 +393,5 @@
warning("Doesn't pass interpreter argument aTHX to Perl_$func");
$file{changes} += $changes;
+ }
}
}
I've also added a test case.
Besides, this uncovered another buglet: There were redundant specs
for Perl_warner() and Perl_warner_nocontext() in ppport.h. This will
also be fixed in the next release.
Thanks,
Marcus