Skip Menu |

This queue is for tickets about the Syntax-Keyword-Try CPAN distribution.

Report information
The Basics
Id: 123547
Status: resolved
Priority: 0/
Queue: Syntax-Keyword-Try

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

Bug Information
Severity: (no value)
Broken in: 0.08
Fixed in: 0.09



Subject: Syntax::Keyword::Try crash (core dump) under threads
The problem rise if package that uses Syntax::Keyword::Try is not loaded before threads starts. gdb: [New LWP 233017] [New LWP 233016] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `perl bin/echelon.pl'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00007f3a50f68a20 in my_keyword_plugin (my_perl=<optimized out>, kw=kw@entry=0x7f3a4c2ccdf8 "use", kwlen=kwlen@entry=3, op=op@entry=0x7f3a525abc28) at lib/Syntax/Keyword/Try.xs:445 445 if(PL_parser && PL_parser->error_count) [Current thread is 1 (Thread 0x7f3a525ae700 (LWP 233017))] OS: Ubuntu 16.04 Perl: 5.22.1
This turns out to be a fundamental design limitation in how the perl core custom keyword hook mechanism works. It's not really thread-safe :( https://rt.perl.org/Public/Bug/Display.html?id=132413 Other syntax-providing modules are also affected by this. E.g. mauke's Functional::Parameters had to fix it similarly: https://github.com/mauke/Function-Parameters/commit/629a4872489218296da5f29a15c1364674d924e6#diff-1b9315a8ea4e0ac2aff114e11a77351aR2330 I've applied the same hack of a fix, which is to borrow the OP_CHECK_MUTEX for a locking structure here, until the custom keyword plugin hook gets its own. This does have a slight limitation that it doesn't work on 5.14, because that mutex was only added on 5.16. For perl 5.14, this race condition remains, and will have to be solved by use Syntax::Keyword::Try; before starting up any additional threads that might dynamically load code later on. -- Paul Evans
I'm going to close this one because it's effectively resolved. Perl 5.16 and above are fine; and 5.14 is fundamentally unresolveable due to its lack of a locking mutex, but a workaround is documented concerning module load order. -- Paul Evans