Loading changes/bug31736 0 → 100644 +3 −0 Original line number Diff line number Diff line o Minor bugfixes (multithreading): - Avoid some undefined behaviour when freeing mutexes. Fixes bug 31736; bugfix on 0.0.7. src/app/config/config.c +5 −1 Original line number Diff line number Diff line Loading @@ -1197,6 +1197,10 @@ init_protocol_warning_severity_level(void) static void cleanup_protocol_warning_severity_level(void) { /* Destroying a locked mutex is undefined behaviour. This mutex may be * locked, because multiple threads can access it. But we need to destroy * it, otherwise re-initialisation will trigger undefined behaviour. * See #31735 for details. */ atomic_counter_destroy(&protocol_warning_severity_level); } Loading src/feature/relay/router.c +4 −0 Original line number Diff line number Diff line Loading @@ -3463,6 +3463,10 @@ router_free_all(void) crypto_pk_free(server_identitykey); crypto_pk_free(client_identitykey); /* Destroying a locked mutex is undefined behaviour. This mutex may be * locked, because multiple threads can access it. But we need to destroy * it, otherwise re-initialisation will trigger undefined behaviour. * See #31735 for details. */ tor_mutex_free(key_lock); routerinfo_free(desc_routerinfo); extrainfo_free(desc_extrainfo); Loading src/lib/crypt_ops/crypto_openssl_mgt.c +4 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,10 @@ crypto_openssl_free_all(void) tor_free(crypto_openssl_version_str); tor_free(crypto_openssl_header_version_str); /* Destroying a locked mutex is undefined behaviour. This mutex may be * locked, because multiple threads can access it. But we need to destroy * it, otherwise re-initialisation will trigger undefined behaviour. * See #31735 for details. */ #ifndef NEW_THREAD_API if (n_openssl_mutexes_) { int n = n_openssl_mutexes_; Loading src/lib/lock/compat_mutex.c +9 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,15 @@ tor_mutex_new_nonrecursive(void) tor_mutex_init_nonrecursive(m); return m; } /** Release all storage and system resources held by <b>m</b>. */ /** Release all storage and system resources held by <b>m</b>. * * Destroying a locked mutex is undefined behaviour. Global mutexes may be * locked when they are passed to this function, because multiple threads can * still access them. So we can either: * - destroy on shutdown, and re-initialise when tor re-initialises, or * - skip destroying and re-initialisation, using a sentinel variable. * See #31735 for details. */ void tor_mutex_free_(tor_mutex_t *m) { Loading Loading
changes/bug31736 0 → 100644 +3 −0 Original line number Diff line number Diff line o Minor bugfixes (multithreading): - Avoid some undefined behaviour when freeing mutexes. Fixes bug 31736; bugfix on 0.0.7.
src/app/config/config.c +5 −1 Original line number Diff line number Diff line Loading @@ -1197,6 +1197,10 @@ init_protocol_warning_severity_level(void) static void cleanup_protocol_warning_severity_level(void) { /* Destroying a locked mutex is undefined behaviour. This mutex may be * locked, because multiple threads can access it. But we need to destroy * it, otherwise re-initialisation will trigger undefined behaviour. * See #31735 for details. */ atomic_counter_destroy(&protocol_warning_severity_level); } Loading
src/feature/relay/router.c +4 −0 Original line number Diff line number Diff line Loading @@ -3463,6 +3463,10 @@ router_free_all(void) crypto_pk_free(server_identitykey); crypto_pk_free(client_identitykey); /* Destroying a locked mutex is undefined behaviour. This mutex may be * locked, because multiple threads can access it. But we need to destroy * it, otherwise re-initialisation will trigger undefined behaviour. * See #31735 for details. */ tor_mutex_free(key_lock); routerinfo_free(desc_routerinfo); extrainfo_free(desc_extrainfo); Loading
src/lib/crypt_ops/crypto_openssl_mgt.c +4 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,10 @@ crypto_openssl_free_all(void) tor_free(crypto_openssl_version_str); tor_free(crypto_openssl_header_version_str); /* Destroying a locked mutex is undefined behaviour. This mutex may be * locked, because multiple threads can access it. But we need to destroy * it, otherwise re-initialisation will trigger undefined behaviour. * See #31735 for details. */ #ifndef NEW_THREAD_API if (n_openssl_mutexes_) { int n = n_openssl_mutexes_; Loading
src/lib/lock/compat_mutex.c +9 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,15 @@ tor_mutex_new_nonrecursive(void) tor_mutex_init_nonrecursive(m); return m; } /** Release all storage and system resources held by <b>m</b>. */ /** Release all storage and system resources held by <b>m</b>. * * Destroying a locked mutex is undefined behaviour. Global mutexes may be * locked when they are passed to this function, because multiple threads can * still access them. So we can either: * - destroy on shutdown, and re-initialise when tor re-initialises, or * - skip destroying and re-initialisation, using a sentinel variable. * See #31735 for details. */ void tor_mutex_free_(tor_mutex_t *m) { Loading