@@ -58,6 +58,7 @@ static void run_dtor_list(dtor_obj **ptr) {
58
58
return ;
59
59
while (* ptr ) {
60
60
dtor_obj * cur = * ptr ;
61
+ fprintf (stderr , "run_dtor_list obj %p\n" , cur -> obj ); fflush (stderr );
61
62
* ptr = cur -> next ;
62
63
cur -> dtor (cur -> obj );
63
64
free (cur );
@@ -87,8 +88,12 @@ int __mingw_cxa_thread_atexit(dtor_fn dtor, void *obj, void *dso) {
87
88
}
88
89
89
90
static void WINAPI tls_atexit_callback (HANDLE __UNUSED_PARAM (hDllHandle ), DWORD dwReason , LPVOID __UNUSED_PARAM (lpReserved )) {
91
+ fprintf (stderr , "tls_atexit_callback reason %d\n" , dwReason );
92
+ fflush (stderr );
90
93
if (dwReason == DLL_PROCESS_DETACH ) {
91
94
dtor_obj * * p = (dtor_obj * * )TlsGetValue (tls_dtors_slot );
95
+ fprintf (stderr , "tls_atexit_callback DLL_PROCESS_DETACH\n" );
96
+ fflush (stderr );
92
97
run_dtor_list (p );
93
98
free (p );
94
99
TlsSetValue (tls_dtors_slot , NULL );
@@ -101,6 +106,8 @@ static void WINAPI tls_callback(HANDLE hDllHandle, DWORD dwReason, LPVOID __UNUS
101
106
dtor_obj * * p ;
102
107
switch (dwReason ) {
103
108
case DLL_PROCESS_ATTACH :
109
+ fprintf (stderr , "tls_callback DLL_PROCESS_ATTACH\n" );
110
+ fflush (stderr );
104
111
if (inited == 0 ) {
105
112
InitializeCriticalSection (& lock );
106
113
__dso_handle = hDllHandle ;
@@ -121,6 +128,8 @@ static void WINAPI tls_callback(HANDLE hDllHandle, DWORD dwReason, LPVOID __UNUS
121
128
inited = 1 ;
122
129
break ;
123
130
case DLL_PROCESS_DETACH :
131
+ fprintf (stderr , "tls_callback DLL_PROCESS_DETACH\n" );
132
+ fflush (stderr );
124
133
/*
125
134
* If there are other threads still running that haven't been detached,
126
135
* we don't attempt to run their destructors (MSVC doesn't either), but
@@ -142,7 +151,11 @@ static void WINAPI tls_callback(HANDLE hDllHandle, DWORD dwReason, LPVOID __UNUS
142
151
* standard says, but differs from what MSVC does with a dynamically
143
152
* linked CRT (which still runs TLS destructors for the main thread).
144
153
*/
154
+ fprintf (stderr , "tls_callback DLL_PROCESS_DETACH1\n" );
155
+ fflush (stderr );
145
156
if (__mingw_module_is_dll ) {
157
+ fprintf (stderr , "tls_callback DLL_PROCESS_DETACH2\n" );
158
+ fflush (stderr );
146
159
p = (dtor_obj * * )TlsGetValue (tls_dtors_slot );
147
160
run_dtor_list (p );
148
161
free (p );
@@ -151,17 +164,31 @@ static void WINAPI tls_callback(HANDLE hDllHandle, DWORD dwReason, LPVOID __UNUS
151
164
* thread local atexit callback, to make sure they don't run when
152
165
* exiting the process with _exit or ExitProcess. */
153
166
run_dtor_list (& global_dtors );
167
+ fprintf (stderr , "tls_callback DLL_PROCESS_DETACH3\n" );
168
+ fflush (stderr );
154
169
TlsFree (tls_dtors_slot );
155
170
}
171
+ fprintf (stderr , "tls_callback DLL_PROCESS_DETACH4\n" );
172
+ fflush (stderr );
156
173
if (inited == 1 ) {
157
174
inited = 0 ;
175
+ fprintf (stderr , "tls_callback DLL_PROCESS_DETACH5\n" );
176
+ fflush (stderr );
158
177
DeleteCriticalSection (& lock );
178
+ fprintf (stderr , "tls_callback DLL_PROCESS_DETACH6\n" );
179
+ fflush (stderr );
159
180
}
181
+ fprintf (stderr , "tls_callback DLL_PROCESS_DETACH7\n" );
182
+ fflush (stderr );
160
183
break ;
161
184
case DLL_THREAD_ATTACH :
185
+ fprintf (stderr , "tls_callback DLL_THREAD_ATTACH\n" );
186
+ fflush (stderr );
162
187
break ;
163
188
case DLL_THREAD_DETACH :
164
189
p = (dtor_obj * * )TlsGetValue (tls_dtors_slot );
190
+ fprintf (stderr , "tls_callback DLL_THREAD_DETACH\n" );
191
+ fflush (stderr );
165
192
run_dtor_list (p );
166
193
free (p );
167
194
TlsSetValue (tls_dtors_slot , NULL );
0 commit comments