Mailing List Archive

POSIX::2008 - panic on perl compiled with DEBUGGING
https://metacpan.org/release/CGPAN/POSIX-2008-0.20/source/2008.xs#L2141

× FAIL 5.38.0-x86_64-linux-thread-multi-quadmath DEBUGGING
× FAIL 5.38.0-x86_64-linux-thread-multi-ld DEBUGGING
× FAIL 5.36.1-x86_64-linux-thread-multi-ld DEBUGGING
? PASS 5.36.1-x86_64-linux-thread-multi no DEBUGGING
× FAIL 5.34.1-x86_64-linux-thread-multi-ld DEBUGGING

This is perl 5, version 38, subversion 0 (v5.38.0) built for x86_64-linux-thread-multi-quadmath
Linux 6.4.3-1-default [openSUSE Tumbleweed 20230716]

POSIX-2008-0.20-0 510 > prove -vwb t/02_fs.t
t/02_fs.t ..
1..77
ok 1 - access(F_OK)
ok 2 - access(R_OK)
ok 3 - access(W_OK)
ok 4 - access(X_OK)
panic: free from wrong pool, 20134f8!=1fdb2a0 at t/02_fs.t line 42.
# Looks like your test exited with 22 just after 4.
Dubious, test returned 22 (wstat 5632, 0x1600)
Failed 73/77 subtests

Test Summary Report
-------------------
t/02_fs.t (Wstat: 5632 (exited 22) Tests: 4 Failed: 0)
Non-zero exit status: 22
Parse errors: Bad plan. You planned 77 tests but ran 4.
Files=1, Tests=4, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.07 cusr 0.01 csys = 0.10 CPU)
Result: FAIL

If I change that test to

my $prp = POSIX::2008::realpath ($tmpname);
my $crp = Cwd::realpath ($tmpname);
is ($prp, $crp, 'realpath ()');

I get

t/02_fs.t ... 1/77 panic: free from wrong pool, 323a3a5849002424!=11e32a0 at t/02_fs.t line 42.

which clearly indicates POSIX::2008::realpath is at fault, but I do not see why
--8<---
char *
realpath(const char *path);
CODE:
errno = 0;
RETVAL = realpath(path, NULL);
OUTPUT:
RETVAL
CLEANUP:
if (RETVAL != NULL)
safesysfree(RETVAL);
-->8---

Changing "safesysfree(RETVAL)" to "Safefree (RETVAL)" - as used in other entries - still panics

--
H.Merijn Brand https://tux.nl Perl Monger http://amsterdam.pm.org/
using perl5.00307 .. 5.37 porting perl5 on HP-UX, AIX, and Linux
https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.org
Re: POSIX::2008 - panic on perl compiled with DEBUGGING [ In reply to ]
"H.Merijn Brand" <perl5@tux.freedom.nl> writes:

> t/02_fs.t ... 1/77 panic: free from wrong pool, 323a3a5849002424!=11e32a0 at t/02_fs.t line 42.
>
> which clearly indicates POSIX::2008::realpath is at fault, but I do not see why
> --8<---
> char *
> realpath(const char *path);
> CODE:
> errno = 0;
> RETVAL = realpath(path, NULL);
> OUTPUT:
> RETVAL
> CLEANUP:
> if (RETVAL != NULL)
> safesysfree(RETVAL);
> -->8---
>
> Changing "safesysfree(RETVAL)" to "Safefree (RETVAL)" - as used in other entries - still panics

From realpath(3posix)¹:

If the resolved_name argument is a null pointer, the pointer
returned by realpath() can be passed to free().

But under DEBUGGING (specifically #ifdef PERL_TRACK_MEMPOOL²),
safesysfree() is not free(), but perl's own memory allocator.

The function should call free() instead of safesysfree() on the returned
pointer (this is also what the $^X code³ does).

- ilmari

¹ https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html
² https://github.com/Perl/perl5/blob/blead/util.c#L375
³ https://github.com/Perl/perl5/blob/blead/caretx.c#L89-L92
Re: POSIX::2008 - panic on perl compiled with DEBUGGING [ In reply to ]
On 7/18/23 05:35, H.Merijn Brand wrote:
> https://metacpan.org/release/CGPAN/POSIX-2008-0.20/source/2008.xs#L2141
>
> × FAIL 5.38.0-x86_64-linux-thread-multi-quadmath DEBUGGING
> × FAIL 5.38.0-x86_64-linux-thread-multi-ld DEBUGGING
> × FAIL 5.36.1-x86_64-linux-thread-multi-ld DEBUGGING
> ? PASS 5.36.1-x86_64-linux-thread-multi no DEBUGGING
> × FAIL 5.34.1-x86_64-linux-thread-multi-ld DEBUGGING
>
> This is perl 5, version 38, subversion 0 (v5.38.0) built for x86_64-linux-thread-multi-quadmath
> Linux 6.4.3-1-default [openSUSE Tumbleweed 20230716]
>
> POSIX-2008-0.20-0 510 > prove -vwb t/02_fs.t
> t/02_fs.t ..
> 1..77
> ok 1 - access(F_OK)
> ok 2 - access(R_OK)
> ok 3 - access(W_OK)
> ok 4 - access(X_OK)
> panic: free from wrong pool, 20134f8!=1fdb2a0 at t/02_fs.t line 42.
> # Looks like your test exited with 22 just after 4.
> Dubious, test returned 22 (wstat 5632, 0x1600)
> Failed 73/77 subtests
>
> Test Summary Report
> -------------------
> t/02_fs.t (Wstat: 5632 (exited 22) Tests: 4 Failed: 0)
> Non-zero exit status: 22
> Parse errors: Bad plan. You planned 77 tests but ran 4.
> Files=1, Tests=4, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.07 cusr 0.01 csys = 0.10 CPU)
> Result: FAIL
>
[snip]

I get these results too.

#####
$ uname -mrs
Linux 5.10.0-18-amd64 x86_64

$ lsb_release -a 2>/dev/null | ack '^Description'
Description: Debian GNU/Linux 11 (bullseye)

$ ./bin/perl -Ilib -V:config_args
config_args='-des -Dusedevel -Dusethreads -Dusequadmath -DDEBUGGING
-Dprefix=/home/jkeenan/testing/perl-5.38.0 -Uversiononly -Dman1dir=none
-Dman3dir=none';

$ ./bin/cpanm POSIX::2008
--> Working on POSIX::2008
Fetching
http://www.cpan.org/authors/id/C/CG/CGPAN/POSIX-2008-0.20.tar.gz ... OK
Configuring POSIX-2008-0.20 ... OK
Building and testing POSIX-2008-0.20 ... FAIL
! Installing POSIX::2008 failed. See
/home/jkeenan/.cpanm/work/1689682163.3385234/build.log for details.
Retry with --force to force install it.

...
PERL_DL_NONLAZY=1 "/home/jkeenan/testing/perl-5.38.0/bin/perl"
"-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef
*Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_use.t .. ok
panic: free from wrong pool, 0!=55790927e2a0 at t/02_fs.t line 42.
# Looks like your test exited with 255 just after 4.
t/02_fs.t ...
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 73/77 subtests
t/03_rw.t ... ok
t/04_at.t ... ok
t/05_is.t ... ok

Test Summary Report
-------------------
t/02_fs.t (Wstat: 65280 (exited 255) Tests: 4 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 77 tests but ran 4.
...
#####