Skip to content

Fix LeakSanitizer leak in CrossNamespacePackTest#9079

Open
parasol-aser wants to merge 1 commit intogoogle:masterfrom
parasol-aser:fix/cross-namespace-unpack-leak
Open

Fix LeakSanitizer leak in CrossNamespacePackTest#9079
parasol-aser wants to merge 1 commit intogoogle:masterfrom
parasol-aser:fix/cross-namespace-unpack-leak

Conversation

@parasol-aser
Copy link
Copy Markdown

Summary

Reproduction

cmake -S . -B build/san -G Ninja -DCMAKE_BUILD_TYPE=Debug \
  -DFLATBUFFERS_CODE_SANITIZE=ON -DFLATBUFFERS_BUILD_TESTS=ON \
  -DFLATBUFFERS_BUILD_CPP17=OFF -DFLATBUFFERS_BUILD_GRPCTEST=OFF \
  -DFLATBUFFERS_BUILD_BENCHMARKS=OFF -DFLATBUFFERS_INSTALL=OFF
cmake --build build/san --target flattests
ctest --test-dir build/san -R '^flattests$' --output-on-failure

Before: 0% tests passed (LSan failure, 48 bytes / 4 allocations).
After: 100% tests passed.

Consumer::UnPack() returns an owning raw pointer (the generated code
does `_o.release()`), so the caller must take ownership. The test added
in google#8948 stored the result in `auto`, leaking the ConsumerT and its
nested allocations -- LSan reports 48 bytes in 4 allocations.

Wrap in std::unique_ptr, matching the pattern already used for the
other UnPack() call site at tests/test.cpp:298 (which deletes
explicitly).
@parasol-aser parasol-aser requested a review from dbaileychess as a code owner May 7, 2026 03:02
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 7, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the c++ label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant