Skip Menu |

This queue is for tickets about the Term-ReadLine-Gnu CPAN distribution.

Maintainer(s)' notes

When you report a bug, please provide the following information;

- output of
	perl -V
	perl Makefile.PL verbose
	make test TEST_VERBOSE=1
	perl -Mblib t/00checkver.t
	echo $TERM
- terminal emulator which you are using
- compiler which is used to compile the GNU Readline Library (libreadline.a) if you can know.
Read INSTALL in the distribution for more details.

Report information
The Basics
Id: 65973
Status: resolved
Priority: 0/
Queue: Term-ReadLine-Gnu

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.20
Fixed in: (no value)



Subject: Broken with Readline 6.2 ( Missing Symbol xmalloc )
/usr/bin/perl: symbol lookup error: /usr/lib64/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi/auto/Term/ReadLine/Gnu/Gnu.so: undefined symbol: xmalloc

http://bugs.gentoo.org/show_bug.cgi?id=355145


On 2011-2月-20 日 21:46:02, KENTNL wrote: Show quoted text
> /usr/bin/perl: symbol lookup error: > /usr/lib64/perl5/vendor_perl/5.12.3/x86_64-linux-thread- > multi/auto/Term/ReadLine/Gnu/Gnu.so: > undefined symbol: xmalloc > > http://bugs.gentoo.org/show_bug.cgi?id=355145
Check if your libreadline.a is broken or not first. You can use some sample files in GNU Readline Library distribution. Then send me the information written in INSTALL file in the Term::ReadLine::Gnu distribution.
Thanks for the reasonably prompt response.

More research has been done, and it appears this is due to a change in something we do in Gentoo, but, based on what it is and why it is, this is a "heads up" because it looks like its an indicator of future changes from Upstream.

Gentoo are doing this on readline now: 

CPPFLAGS+=" -Dxrealloc=_rl_realloc -Dxmalloc=_rl_malloc -Dxfree=_rl_free "

And this is a workaround for this bug: 

http://lists.gnu.org/archive/html/bug-readline/2010-07/msg00013.html

Even if upstream don't do it, I hope this bug report can serve as a possible heads-up to other distribution maintainers if they try doing the same thing.

If Term-ReadLine-Gnu do not wish to / are unable to solve this problem as well on their end ( I don't think they are at this stage ), then a work-around that downstream distributions can perform is trying to stuff this variable into make:

      PASTHRU_DEFINE = -Dxrealloc=_rl_realloc -Dxmalloc=_rl_malloc -Dxfree=_rl_free

Or something similar.

hope that helps =)



From: vitaliy.tokarev [...] gmail.com
On Mon Feb 21 12:34:30 2011, KENTNL wrote: Show quoted text
> Gentoo are doing this on readline now: > > CPPFLAGS+=" -Dxrealloc=_rl_realloc -Dxmalloc=_rl_malloc > -Dxfree=_rl_free "
Thanks for solution! Easy way in cpan console type: o conf makepl_arg 'CCFLAGS=" -Dxrealloc=_rl_realloc - Dxmalloc=_rl_malloc -Dxfree=_rl_free "' test Term::ReadLine::Gnu or install Term::ReadLine::Gnu
On Sun Feb 20 21:46:02 2011, KENTNL wrote: Show quoted text
> /usr/bin/perl: symbol lookup error: > /usr/lib64/perl5/vendor_perl/5.12.3/x86_64-linux-thread- > multi/auto/Term/ReadLine/Gnu/Gnu.so: > undefined symbol: xmalloc > > http://bugs.gentoo.org/show_bug.cgi?id=355145
I have attached a patch to Term-ReadLine-Gnu Makefile.PL. With this patch I was able to compile and test Term::ReadLine::Gnu successfully on Gentoo Linux. Could this be included in version 1.21?
Subject: Term-ReadLine-Gnu-1.20-xmalloc.patch
diff -ru Term-ReadLine-Gnu-1.20/Makefile.PL Term-ReadLine-Gnu-1.20-hax/Makefile.PL --- Term-ReadLine-Gnu-1.20/Makefile.PL 2010-05-02 12:37:55.000000000 +0200 +++ Term-ReadLine-Gnu-1.20-hax/Makefile.PL 2013-10-29 09:55:08.000000000 +0100 @@ -90,6 +90,11 @@ } } +# Check whether xmalloc has been renamed to _rl_malloc (Gentoo Linux) +if (my $extra_defs = guess_malloc_names($RLINC, $RLLIB, $defs, $lddflags, $libs)) { + $defs .= " $extra_defs"; +} + # generate a Makefile WriteMakefile ( @@ -105,7 +110,7 @@ ) : () ), INC => $RLINC, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz' }, - clean => { FILES => "rlver.c rlver$Config{_exe}" }, + clean => { FILES => "rlver.c rlver$Config{_exe} rlmalloc.c rlmalloc$Config{_exe}" }, ); if ($Config{usesfio} eq 'true') { @@ -214,4 +219,76 @@ # $rlver may be '8.21-beta3' or '4.2a' return $rlver =~ /(\d+)\.(\d+)/; } + +######################################################################## +# Check whether the xmalloc exported by readline is indeed called +# 'xmalloc' or whether it has been renamed to '_rl_malloc'. +sub guess_malloc_names { + my ($RLINC, $RLLIB, $defs, $lddflags, $libs) = @_; + my $frlmalloc = 'rlmalloc.c'; + + my @symbol_sets = ( + { + # try defaults first + # xmalloc => 'xmalloc', + # xrealloc => 'xrealloc', + # xfree => 'xfree', + }, + { + xmalloc => '_rl_malloc', + xrealloc => '_rl_realloc', + xfree => '_rl_free', + }, + ); + + # make temp file + open(my $F, ">", $frlmalloc) || die "Cannot open $frlmalloc: $!\n"; + print {$F} <<'EOF'; +/* used by Makefile.pl to check the names of xmalloc etc. of the GNU Readline Library */ +#include <stdio.h> +#include <readline/readline.h> + +/* we assume support for ANSI C */ +extern void *xmalloc(int); +extern void *xrealloc(void *, int); +extern void xfree(void *); + +int main() { + char *p; + p = xmalloc(1); + p[0] = 'o'; + p = xrealloc(p, 3); + p[1] = 'k'; + p[2] = '\0'; + puts(p); + xfree(p); + return 0; +} +EOF + close($F); + + my $extra_defs; + for my $symbol_set (@symbol_sets) { + my $xdef = join " ", map "-D$_=$symbol_set->{$_}", sort keys %$symbol_set; + # compile it + my $comp_cmd = "$Config{cc} $RLINC $Config{ccflags} $defs $xdef $frlmalloc -o rlmalloc $RLLIB $lddflags $Config{ldflags} $libs"; + print $comp_cmd, "\n"; + system($comp_cmd); + unless (system($comp_cmd) || `./rlmalloc` !~ /^ok$/ || $?) { + $extra_defs = $xdef; + last; + } + } + + unless (defined $extra_defs) { + warn <<EOM; +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +I was unable to find a working xmalloc in your readline library. +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +EOM + exit $err; + } + + return $extra_defs; +} # End of Makefile.PL
I've released Term::ReadLine::Gnu 1.21 which includes your patch. Thank you.