Add tracepoint_disable_destructors()
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 47 lines · ----- On Mar 10, 2016, at 9:44 AM, Mathieu Desnoyers…
Calling this function from an instrumented program allows disabling tracepoint destructors. This allows threads to continue calling tracepoint code even after the tracepoint destructors have run. This is needed for applications that exit without joining all their threads.
Signed-off-by Mathieu Desnoyers <[email protected]>CC Jeffrey Chen <[email protected]>---
include/lttng/tracepoint.h| 19 +++++++++++++++++--1 file changed, 17 insertions(+), 2 deletions(-)include/lttng/tracepoint.h +16
-1@@ -227,6 +227,21 @@ struct lttng_ust_tracepoint_dlopen {extern struct lttng_ust_tracepoint_dlopen tracepoint_dlopen; +/* Disable tracepoint destructors. */ +int __tracepoints__disable_destructors __attribute__((weak)); + +/* +* Programs that have threads that survive after they exit, and +* therefore call library destructors, should disable the tracepoint +* destructors by calling tracepoint_disable_destructors(). This will +* leak the tracepoint instrumentation library shared object, leaving +* its teardown to the operating system process teardown. +*/ +static inline void tracepoint_disable_destructors (void ) +{ + __tracepoints__disable_destructors =1 ; +} +#if defined(TRACEPOINT_DEFINE ) || defined(TRACEPOINT_CREATE_PROBES )/* @@ -299,7 +314,7 @@ __tracepoints__destroy(void) {int ret; -if (--__tracepoint_registered) +if (--__tracepoint_registered || __tracepoints__disable_destructors)return ;if (tracepoint_dlopen.liblttngust_handle && !__tracepoint_ptrs_registered) { ret =dlclose (tracepoint_dlopen.liblttngust_handle);
include/lttng/tracepoint.h __tracepoints__ptrs_destroy(void) · line 423
Quoted 8 lines
include/lttng/tracepoint.h +1
-1@@ -402,7 +417,7 @@ __tracepoints__ptrs_destroy(void) {int ret; -if (--__tracepoint_ptrs_registered) +if (--__tracepoint_ptrs_registered || __tracepoints__disable_destructors)return ;if (tracepoint_dlopen.tracepoint_unregister_lib) tracepoint_dlopen.tracepoint_unregister_lib (__start___tracepoints_ptrs);
We could probably let the library unregister itself even if the destructors are disabled: it will unregister all tracepoint callsites associated with that library, which appears to be a cleaner teardown. It would only leave the tracepoint_dlopen structure content in place, and leak the lttng-ust-tracepoint shared object.
I'm also wondering if leaking this shared object should become the default behavior, since it appears that it makes lttng-ust more robust against application that leave their threads running after the destructors.
Thoughts ?
Thanks,
Mathieu
Quoted 2 lines
--
2.1.4
Signature · 7 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev