develooper Front page | perl.perl5.porters | Postings from September 2019

[perl #134444] Loading IO::Handle not thread safe

Thread Previous
From:
James E Keenan via RT
Date:
September 22, 2019 15:42
Subject:
[perl #134444] Loading IO::Handle not thread safe
Message ID:
rt-4.0.24-1886-1569166920-1690.134444-15-0@perl.org
On Fri, 20 Sep 2019 16:09:16 GMT, ss@atikon.com wrote:
> Hi,
>  When embedding perl in a multi threaded program, loading IO::Handle
>  concurrently in multiple threads (each with their own interpreter)
> will cause
>  compilation errors in other threads and in unrelated modules. The
> errors all
>  look like missing symbols that should be there, like undefined
> subroutines or
> methods or imported subs not there causing errors like this:
>  String found where operator expected at
> /usr/lib/perl5/5.28.1/SelectSaver.pm
>  line 42, near "croak 'usage: SelectSaver->new( [FILEHANDLE] )'"  (Do
> you need
>  to predeclare croak?) syntax error at
> /usr/lib/perl5/5.28.1/SelectSaver.pm
> line 42, near "croak 'usage: SelectSaver->new( [FILEHANDLE] )'"
> 
> The errors can be reproduced using the attached C program which I
> compiled
> with:  gcc -Wall testthreads.c -Wl,-E -Wl,-
> rpath,/usr/lib/perl5/5.28.1/x86_64-
> linux-thread-multi/CORE    -L/usr/local/lib64 -fstack-protector-strong
> -L/
> usr/lib/perl5/5.28.1/x86_64-linux-thread-multi/CORE -lperl -lm -ldl
> -lcrypt -
> lpthread -D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fwrapv
> -fno-
> strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -
>  D_FILE_OFFSET_BITS=64  -I/usr/lib/perl5/5.28.1/x86_64-linux-thread-
> multi/CORE
> -o testthreads -fPIC -g testthreads.c

I built a threaded perl at blead and then tried to compile your test program.  The compilation failed.

#####
$ gcc -Wall 134444-testthreads.c -Wl,-E -Wl,-rpath,/home/jkeenan/testing/threaded_blead/lib/perl5/5.31.5/x86_64-linux-thread-multi/CORE \
> -L/usr/local/lib64 -fstack-protector-strong  \
> -L/home/jkeenan/testing/threaded_blead/lib/perl5/5.31.5/x86_64-linux-thread-multi/CORE -lperl -lm -ldl \
> -lcrypt -lpthread -D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fwrapv -fno-strict-aliasing \
> -pipe -fstack-protector-strong -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  \
> -I/home/jkeenan/testing/threaded_blead/lib/perl5/5.31.5/x86_64-linux-thread-multi/CORE  \
> -o testthreads -fPIC -g 134444-testthreads.c
/tmp/ccCfdXuT.o: In function `p5_init_perl':
/home/jkeenan/learn/perl/p5p/134444-testthreads.c:16: multiple definition of `p5_init_perl'
/tmp/ccQrNdU4.o:/home/jkeenan/learn/perl/p5p/134444-testthreads.c:16: first defined here
/tmp/ccCfdXuT.o: In function `p5_destruct_perl':
/home/jkeenan/learn/perl/p5p/134444-testthreads.c:28: multiple definition of `p5_destruct_perl'
/tmp/ccQrNdU4.o:/home/jkeenan/learn/perl/p5p/134444-testthreads.c:28: first defined here
/tmp/ccCfdXuT.o: In function `p5_eval_pv':
/home/jkeenan/learn/perl/p5p/134444-testthreads.c:40: multiple definition of `p5_eval_pv'
/tmp/ccQrNdU4.o:/home/jkeenan/learn/perl/p5p/134444-testthreads.c:40: first defined here
/tmp/ccCfdXuT.o: In function `thread_code':
/home/jkeenan/learn/perl/p5p/134444-testthreads.c:62: multiple definition of `thread_code'
/tmp/ccQrNdU4.o:/home/jkeenan/learn/perl/p5p/134444-testthreads.c:62: first defined here
/tmp/ccCfdXuT.o: In function `main':
/home/jkeenan/learn/perl/p5p/134444-testthreads.c:71: multiple definition of `main'
/tmp/ccQrNdU4.o:/home/jkeenan/learn/perl/p5p/134444-testthreads.c:71: first defined here
collect2: error: ld returned 1 exit status
#####

Can you spot the problem?

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

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

Thread Previous


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