Skip Menu |

This queue is for tickets about the Math-Prime-Util CPAN distribution.

Maintainer(s)' notes

The latest version is in https://github.com/danaj/Math-Prime-Util

    git clone --origin upstream git://github.com/danaj/Math-Prime-Util.git Math-Prime-Util

Comments, issues, and patches are welcome at either RT or github, or send me email.

Report information
The Basics
Id: 83623
Status: resolved
Priority: 0/
Queue: Math-Prime-Util

People
Owner: DANAJ [...] cpan.org
Requestors: DANAJ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.11
  • 0.12
  • 0.13
  • 0.14
  • 0.15
  • 0.16
  • 0.17
  • 0.18
  • 0.19
  • 0.20
  • 0.21
Fixed in: 0.22



Subject: Threading issues
Testing with threads fails on some machines. NetBSD consistently, OpenBSD inconsistently. Cygwin on the latest versions. They work fine on Linux, Darwin, Solaris, Strawberry Win32, and some others. The #perl wisdom is "screw threads, never test with them, and disregard all bug reports where the user was using threads." This seems harsh for a library that ought to be able to be used in a threaded environment. I believe the underlying issue is a particular issue with pthreads mutexes. The primes cache is managed by a readers/writers solution, and mutexes are used. At some point we get this scenario: A reads: lock access mutex. reader_count++. read... read... B reads: reader_count++. read... read... A done: reader_count--. B done: reader_count--. unlock access mutex. The issue is that thread A did the lock, and thread B did the unlock. This is undefined behavior, and the BSD's are being strict about ownership. The cache.c code needs to move to using pthread_cond_* for management.
Tentatively fixed in 0.22. Threading locks moved to pthread condition variables (with a mutex lock of course). Test 31-threading.t changed to run on every platform. However, only no NetBSD and only a few OpenBSD results have been returned yet, so waiting to resolve this.
Tested with Cygwin and NetBSD with threads, no errors. Still waiting for CPAN Testers.
Seems to be resolved on all O/S's, but as usual the testing on NetBSD is very thin. I have tested it on the one NetBSD machine I have access to with threading on, and it passes all the threading tests.