MantisBT - JANA
View Issue Details
0000210JANABugpublic2012-03-21 10:582012-03-21 11:49
davidl 
davidl 
normalmajorsometimes
resolvedfixed 
0000210: program hangs when merging threads at end
A JANA program can hang at the end of processing just after printing a message like: "Merging thread 0".

The reason for this is because the JEventLoop destructor calls RemoveJEventLoop which adds the thread to the "threads_to_be_joined" vector. If this happens while the main (monitoring) thread is inside of the application mutex lock, it can call pthread_join while the mutex is locked. Meanwhile, the JEventLoop destructor tries calling JApplication::AddFactoriesToDeleteList(). This tries locking the application mutex, but can't since it is already locked by the main thread. Thus, the JEventLoop destructor never exits and consequently, pthread_exit is never called making pthread_join block forever.

One solution for this would be to create a separate mutex for controlling access to the factories_to_delete container.
No tags attached.
Issue History
2012-03-21 10:58davidlNew Issue
2012-03-21 11:49davidlNote Added: 0000315
2012-03-21 11:49davidlStatusnew => resolved
2012-03-21 11:49davidlResolutionopen => fixed
2012-03-21 11:49davidlAssigned To => davidl

Notes
(0000315)
davidl   
2012-03-21 11:49   
I added a factories_to_delete_mutex to JApplication that is used to synchronize access to the factories_to_delete vector. No testing has been done yet to confirm that this actually solves the problem (but it should!)