Bug 1104827
Summary: | Perl core-dumps if a hash is tied to SDBM_File before spawning a thread | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 6 | Reporter: | Terry Bowling <tbowling> | ||||||||||||
Component: | perl | Assignee: | Petr Pisar <ppisar> | ||||||||||||
Status: | CLOSED ERRATA | QA Contact: | Martin Kyral <mkyral> | ||||||||||||
Severity: | medium | Docs Contact: | |||||||||||||
Priority: | urgent | ||||||||||||||
Version: | 6.5 | CC: | fkrska, jkurik, jorton, mkyral, ppisar, psabata, rvokal | ||||||||||||
Target Milestone: | rc | Keywords: | Patch, ZStream | ||||||||||||
Target Release: | 6.7 | ||||||||||||||
Hardware: | All | ||||||||||||||
OS: | Linux | ||||||||||||||
URL: | https://rt.perl.org/Ticket/Display.html?id=61912 | ||||||||||||||
Whiteboard: | |||||||||||||||
Fixed In Version: | perl-5.10.1-137.el6 | Doc Type: | Bug Fix | ||||||||||||
Doc Text: |
Due to creating threads after tying a variable to an SDBM database using the SDBM_File Perl module, the Perl interpreter terminated unexpectedly when terminating Perl threads. With this update, the DB_File, GDBM_File, NDBM_File, ODBM_File, and SDBM_File Perl modules have been modified to destroy their objects only from the thread context which created the objects. As a result, the destructors of the aforementioned file objects are now thread-safe. Note, however, that other operations on the objects cannot be called from other threads. In general, the DB_File, GDBM_File, NDBM_File, ODBM_File, and SDBM_File Perl modules remain thread-unsafe.
|
Story Points: | --- | ||||||||||||
Clone Of: | |||||||||||||||
: | 1107542 1161103 (view as bug list) | Environment: | |||||||||||||
Last Closed: | 2015-07-22 05:59:34 UTC | Type: | Bug | ||||||||||||
Regression: | --- | Mount Type: | --- | ||||||||||||
Documentation: | --- | CRM: | |||||||||||||
Verified Versions: | Category: | --- | |||||||||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||||||||
Embargoed: | |||||||||||||||
Bug Depends On: | |||||||||||||||
Bug Blocks: | 1075802, 1159820, 1161103 | ||||||||||||||
Attachments: |
|
Description
Terry Bowling
2014-06-04 18:33:59 UTC
Request to keep this BZ public for customer visibility. This happens with any perl, even the development version. Created attachment 902406 [details]
Minimal reproducer
Created attachment 902531 [details]
Three-thread reproducer
Unfortunately the 2-thread "Minimal reproducer" does not fail always. This test uses a thread more which is more reliable.
While I understand the surprise from the the crash, I believe this is intended behavior. You create an object (the tie() call) which allocates a global resource (opens a database by sdbm_open()), then create a bunch of threads which duplicates the object making each replica private to each respective thread. Then when each thread terminates, each replica is destroyed independently (and possibly concurrently) which involves deallocating a global resource (close a database by sdbm_close()). Because sdbm library is not thread-safe, the database handle gets closed multiple times leading to the crash. Obvious solution is to untie the variable before spawning a new thread. While it could be possible to improve the SDBM_File module to globally track each tied database so that each database got closed only once when destroying the tied hash, it would not still not make the module completely thread-safe. E.g. any store operation would corrupted data visible from other threads. Additionally I'd like to quote "Thread-Safe Modules" paragraph from perlthrtut manual: Not all modules that you might use are thread-safe, and you should always assume a module is unsafe unless the documentation says otherwise. This includes modules that are distributed as part of the core. SDBM_File documentation does not declare the thread-safety. Created attachment 907058 [details]
Fix proposed to upstream
Created attachment 907181 [details]
Automated test case for GDBM_File, NDBM_File, ODBM_File, SDBM_File
This tests GDBM_File, NDBM_File, ODBM_File, SDBM_File.
Separate patch (and maybe a test) will be provided for DB_File as it has different upstream.
Created attachment 907248 [details]
DB_File fix proposed to upstream
Test available => qa_ack for rhel-6.6.z *** Bug 1169705 has been marked as a duplicate of this bug. *** Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2015-1266.html |