Uh oh!
There was an error while loading. Please reload this page.
Double Free Fix for 2026.07 - #78
Merged
Merged
Conversation
…eformatUtils The *SanityTests binaries aborted at process exit on Linux with "double free or corruption (fasttop)". The tests themselves passed; the abort happened during static-destructor teardown (_dl_fini -> libfileformatUtils.so __cxa_finalize -> std::string dtor). Root cause: GoogleTest is statically linked and was embedded into BOTH the shared libfileformatUtils.so (which compiled the test helper test.cpp and linked GTest::gtest PUBLIC) AND every test executable. GoogleTest's global command-line-flag std::strings therefore collapsed to a single address under the ELF flat namespace, but each module registered its own __cxa_atexit finalizer, so the one object's destructor ran twice -> double free. macOS (two-level namespace) and Windows were unaffected, which is why only the ubuntu-22.04 jobs failed. Fix: move the test-only helper (test.cpp/test.h) into a new STATIC library fileformatUtilsTest that links GTest, and stop linking GTest into the shared fileformatUtils runtime library. GTest now lives only in the static helper and the test executables, so there is a single set of GTest globals per process and a single destructor. The test helper gets its own empty USDFFUTILSTEST_API macro since a static library linked directly into each executable needs no import/export decoration (this also keeps Windows /WX happy). All test targets that used the helper now link fileformatUtilsTest, which brings fileformatUtils in transitively. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix double-free at test teardown by splitting GTest out of shared fileformatUtils
The *SanityTests binaries aborted at process exit on Linux with "double free or corruption (fasttop)". The tests themselves passed; the abort happened during static-destructor teardown (_dl_fini -> libfileformatUtils.so __cxa_finalize -> std::string dtor).
Root cause: GoogleTest is statically linked and was embedded into BOTH the shared libfileformatUtils.so (which compiled the test helper test.cpp and linked GTest::gtest PUBLIC) AND every test executable. GoogleTest's global command-line-flag std::strings therefore collapsed to a single address under the ELF flat namespace, but each module registered its own __cxa_atexit finalizer, so the one object's destructor ran twice -> double free. macOS (two-level namespace) and Windows were unaffected, which is why only the ubuntu-22.04 jobs failed.
Fix: move the test-only helper (test.cpp/test.h) into a new STATIC library fileformatUtilsTest that links GTest, and stop linking GTest into the shared fileformatUtils runtime library. GTest now lives only in the static helper and the test executables, so there is a single set of GTest globals per process and a single destructor. The test helper gets its own empty USDFFUTILSTEST_API macro since a static library linked directly into each executable needs no import/export decoration (this also keeps Windows /WX happy). All test targets that used the helper now link fileformatUtilsTest, which brings fileformatUtils in transitively.