Page MenuHomeFreeBSD

D56053.id174405.diff
No OneTemporary

D56053.id174405.diff

diff --git a/lib/libc/stdlib/cxa_thread_atexit_impl.c b/lib/libc/stdlib/cxa_thread_atexit_impl.c
--- a/lib/libc/stdlib/cxa_thread_atexit_impl.c
+++ b/lib/libc/stdlib/cxa_thread_atexit_impl.c
@@ -59,7 +59,7 @@
* prevent the crash.
*/
-#define CXA_DTORS_ITERATIONS 4
+#define CXA_DTORS_ITERATIONS 1024
struct cxa_thread_dtor {
void *obj;
@@ -69,6 +69,7 @@
};
static _Thread_local LIST_HEAD(dtor_list, cxa_thread_dtor) dtors =
LIST_HEAD_INITIALIZER(dtors);
+static _Thread_local u_long dtors_cnt;
int
__cxa_thread_atexit_impl(void (*dtor_func)(void *), void *obj,
@@ -94,6 +95,7 @@
new_dtor->func = dtor_func;
new_dtor->dso = dso_symbol;
LIST_INSERT_HEAD(&dtors, new_dtor, entry);
+ dtors_cnt++;
return (0);
}
@@ -111,20 +113,22 @@
(void *)(dtor->func));
}
-static void
-walk_cb_nocall(struct cxa_thread_dtor *dtor __unused)
-{
-}
-
static void
cxa_thread_walk(void (*cb)(struct cxa_thread_dtor *))
{
struct cxa_thread_dtor *dtor;
+ u_long cnt, precnt;
+ precnt = dtors_cnt * CXA_DTORS_ITERATIONS;
while ((dtor = LIST_FIRST(&dtors)) != NULL) {
LIST_REMOVE(dtor, entry);
- cb(dtor);
+ if (cb != NULL)
+ cb(dtor);
free(dtor);
+ cnt++;
+
+ if (cnt > precnt && cb != NULL)
+ break;
}
}
@@ -136,16 +140,13 @@
void
__cxa_thread_call_dtors(void)
{
- int i;
-
- for (i = 0; i < CXA_DTORS_ITERATIONS && !LIST_EMPTY(&dtors); i++)
- cxa_thread_walk(walk_cb_call);
+ cxa_thread_walk(walk_cb_call);
if (!LIST_EMPTY(&dtors)) {
fprintf(stderr, "Thread %p is exiting with more "
"thread-specific dtors created after %d iterations "
"of destructor calls\n",
- _pthread_self(), i);
- cxa_thread_walk(walk_cb_nocall);
+ _pthread_self(), CXA_DTORS_ITERATIONS);
+ cxa_thread_walk(NULL);
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 24, 12:32 PM (14 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30504556
Default Alt Text
D56053.id174405.diff (1 KB)

Event Timeline