develooper Front page | perl.perl5.porters | Postings from November 2017

[perl #132131] Missing feature flag -D_GNU_SOURCE on Linux/musl

From:
James E Keenan via RT
Date:
November 20, 2017 15:10
Subject:
[perl #132131] Missing feature flag -D_GNU_SOURCE on Linux/musl
Message ID:
rt-4.0.24-6156-1511190641-1152.132131-15-0@perl.org
On Tue, 19 Sep 2017 17:37:54 GMT, leah@vuxu.org wrote:
> 
> 
> This is a bug report for perl from leah@vuxu.org,
> generated with the help of perlbug 1.40 running under perl 5.26.0.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> (Please note that this bug report applies to perl 5.26.0 on
> a Linux 4.12 x86_64 system with musl libc 1.1.6.)
> 

For reference:  https://en.wikipedia.org/wiki/Musl

> Perl 5.26.0 uses memmem in fbm_instr via ninstr if available,
> but this function can be defined only when a feature flag like
> _GNU_SOURCE is set.
> 
> Currently, perl detects memmem on musl (because the symbol is there),
> but doesn't define _GNU_SOURCE, so no prototype is declared and the
> return value is assumed to be an int, thus line 951 of util.c
> will truncate the pointer into a 32-bit value, and
> little_p - big_p in pp_index is suddenly very big. ;)
> 
> This resulted in the following script
> 
> my $fn = 'Class/Inspector.pm';
> print index('lib/Class/Inspector.pm', $fn);
> print "\n";
> print  index('lib/Class/Inspector.pm', 'Class/Inspector.pm');
> 
> printing
> 
> % perl /tmp/foo.pl
> -94012539142140
> 4
> 
> Forcing the use of _GNU_SOURCE (as seen below in ccflags) fixes the
> issue,
> perhaps there is a better test.
> 

Also for reference:  locations in the core distribution which mention _GNU_SOURCE:

$ ack -l _GNU_SOURCE . |sort
config_h.SH
cpan/Config-Perl-V/t/21_plv58.t
cpan/Config-Perl-V/t/27_plv5200.t
cpan/Config-Perl-V/t/27_plv5202.t
cpan/Config-Perl-V/t/28_plv5220.t
cpan/Config-Perl-V/t/30_plv5240.t
cpan/Config-Perl-V/t/31_plv52511.t
cpan/Config-Perl-V/t/32_plv5261rc1.t
hints/cygwin.sh
hints/freemint.sh
hints/gnu.sh
hints/linux.sh
NetWare/config_H.wc
plan9/config_h.sample
plan9/config.plan9
Porting/config_H
uconfig.h
win32/config_H.ce
win32/config_H.gc
win32/config_H.vc

Can someone familiar with ccflags take a look at this ticket?  Could the OP's concern be accommodated somewhere in a hints file?

Thank you very much.
-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=132131



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About