mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
fix pthread mutex and condition leak
Hi, I did some more tests with my x86 QNX Avian port and found one major problem in Avian VM while trying to run Apache Ivy. The problem manifests as follows: 1. MySystem::Thread X is created, during its creation pthread mutex and conditional variable are initialized 2. Program runs for some time 3. MySystem Thread X is disposed, it's memory is freed (during garbage collection I guess) 4. Program runs for some time 5. MySystem::Thread Y is created in exactly the same memory address as MySystem::Thread X disposed in step 3 (I suppose that's due to the way memory allocator works in Avian) 6. During MySystem::Thread Y creation pthread mutex and conditional variable initialization fail silently with EBUSY. QNX documentation says it means "The given mutex was previously initialized and hasn't been destroyed." which is correct, because it's exactly in the same memory address as mutex and conditional variable of MySystem::Thread X and they haven't been destroyed during MySystem::Thread X disposal Fortunately solution for this is easy, see the attached patch. Now Apache Ivy works without any problems. Regards, Stanisław Szymczyk
This commit is contained in:
parent
2b44fb6b93
commit
de1f5c7b9f
@ -173,6 +173,8 @@ class MySystem: public System {
|
||||
}
|
||||
|
||||
virtual void dispose() {
|
||||
pthread_mutex_destroy(&mutex);
|
||||
pthread_cond_destroy(&condition);
|
||||
::free(this);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user