Issue 123001 - OS/2 sys 3170 when application exits
Summary: OS/2 sys 3170 when application exits
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: 4.0.0
Hardware: All OS/2
: P3 Normal (vote)
Target Milestone: 4.1.0
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 118923
  Show dependency tree
 
Reported: 2013-08-10 10:26 UTC by Yuri Dario
Modified: 2014-02-10 09:30 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Yuri Dario 2013-08-10 10:26:33 UTC
A stack exception is raised on most exits.
 vcl layer is already closed.
stack is corrupted.
Comment 1 Yuri Dario 2013-11-08 09:55:41 UTC
This issue is related to two different bugs: 
1) in pthread emulation, destroy of mutex leaves it in wrong state, fixed in ports svn at netlabs.org;
2) threads are killed before dll unloading (affects SAL3 cache thread).

Bug #2 has been difficult to discover. SAL3 starts a thread for cache monitoring using at dll loading using global constructor. Then it declares a function as __attribute__(destructor) to call it on unloading.
But when the main process exits with exit(), the runtime in the end calls DosExit and then unloads dlls. But DosExit kills all running threads, so the destructor function does not find the running thread.
The solution is to declare such function in atexit.
Comment 2 Yuri Dario 2013-11-08 10:17:02 UTC
Using atexit() make the function to be called from exit() handling before calling DosExit, thus the thread is still alive.
Comment 3 SVN Robot 2013-11-08 10:26:33 UTC
"ydario" committed SVN revision 1539964 into trunk:
i123001 - force destructor to be called before libc calls DosExit().
Comment 4 SVN Robot 2013-11-08 10:26:34 UTC
"ydario" committed SVN revision 1539965 into trunk:
i123001 - force destructor to be called before libc calls DosExit().
Comment 5 Yuri Dario 2013-11-08 10:36:37 UTC
The same tecnique is not necessary with alloc_arena, alloc_global and locale since they do not start threads and calling them at unloading time is fine.