Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
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.
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 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.
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