Skip to content

hold original pointer along with aligned to get rid of possibly lost memory leak#1872

Closed
TaeZStkyoht wants to merge 1 commit into
abseil:masterfrom
TaeZStkyoht:fix_possible_memory_leak_problem_on_entropy_pool
Closed

hold original pointer along with aligned to get rid of possibly lost memory leak#1872
TaeZStkyoht wants to merge 1 commit into
abseil:masterfrom
TaeZStkyoht:fix_possible_memory_leak_problem_on_entropy_pool

Conversation

@TaeZStkyoht
Copy link
Copy Markdown

@TaeZStkyoht TaeZStkyoht commented Apr 14, 2025

Unless pointers have been hold by an object, it's a lost on valgrind's logic. Even we don't free it, we must hold it. In this case, original pointers were not held.

Because gRPC uses this library, grpc usage was creating this memory leak.

before this change:
LEAK SUMMARY:
definitely lost: 0 bytes in 0 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 1,408 bytes in 4 blocks
still reachable: 1,408 bytes in 4 blocks
suppressed: 0 bytes in 0 blocks

after this change:
LEAK SUMMARY:
definitely lost: 0 bytes in 0 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
still reachable: 2,816 bytes in 8 blocks
suppressed: 0 bytes in 0 blocks

Still reachable is not a problem for valgrind.

Thank you for your contribution to Abseil!

Before submitting this PR, please be sure to read our contributing
guidelines
.

If you are a Googler, please also note that it is required that you send us a
Piper CL instead of using the GitHub pull-request process. The code propagation
process will deliver the change to GitHub.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 14, 2025

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.

@TaeZStkyoht TaeZStkyoht force-pushed the fix_possible_memory_leak_problem_on_entropy_pool branch 6 times, most recently from 92322a4 to 23132ed Compare April 14, 2025 10:19
@TaeZStkyoht
Copy link
Copy Markdown
Author

Why did "Windows MSVC 2022 C++17 Bazel (Optimized)" fail? I cannot see job logs. If I saw it, I would try to fix it.

…memory leak

Unless pointers have been hold by an object, it's a lost on valgrind's logic. Even we don't free it, we must hold it. In this case, original pointers were not held.

Because gRPC uses this library, grpc usage was creating this memory leak.

before this change:
LEAK SUMMARY:
   definitely lost: 0 bytes in 0 blocks
   indirectly lost: 0 bytes in 0 blocks
     possibly lost: 1,408 bytes in 4 blocks
   still reachable: 1,408 bytes in 4 blocks
        suppressed: 0 bytes in 0 blocks

after this change:
LEAK SUMMARY:
   definitely lost: 0 bytes in 0 blocks
   indirectly lost: 0 bytes in 0 blocks
     possibly lost: 0 bytes in 0 blocks
   still reachable: 2,816 bytes in 8 blocks
        suppressed: 0 bytes in 0 blocks

Still reachable is not a problem for valgrind.

Signed-off-by: Oguzhan Turk <stkyoht@hotmail.com>
@TaeZStkyoht TaeZStkyoht force-pushed the fix_possible_memory_leak_problem_on_entropy_pool branch from 23132ed to b0856c4 Compare April 14, 2025 19:04
@derekmauro
Copy link
Copy Markdown
Member

Thank you for letting us know about this issue. The failure is an infrastructure flake.

While this fix does work, I think using alignas is a simpler solution. I'm testing that now.

copybara-service Bot pushed a commit that referenced this pull request Apr 21, 2025
for the Randen entropy pool.

#1872 reports that since
we leak the pointer but no variable holds its address, Valgrind
reports a leak. The PR contains a proposed fix, but I believe this
is simpler.

PiperOrigin-RevId: 749868815
Change-Id: I222fc3202b7a38b8ff960c2398dbf2636e60e490
@derekmauro
Copy link
Copy Markdown
Member

0122890 should fix this issue.

@derekmauro derekmauro closed this Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants