-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing pvalloc memleak test #4733
Conversation
@chenhengqi is anything additional needed for this test? can we close this? |
I have a question about 'Request to allocate 30K bytes to pvalloc(), results in allocating 3*64Kb in return'. From the 'man pvalloc', we have
So the allocation size should be multiple of page size. So in your case, it should be 64Kb, right? The following is an example on x86_64 which has 4KB as the page size,
So requesting 1000 bytes and get 4096 (4KB) bytes. Could you double check in your env why it is 3 *64KB not 64KB? |
Please find 2 outputs below: ASAN_OPTIONS=detect_leaks=1 ./a.out ================================================================= Direct leak of 65536 byte(s) in 1 object(s) allocated from: SUMMARY: AddressSanitizer: 65536 byte(s) leaked in 1 allocation(s). Failure from "make test" log : 196608 is 3 pages of 64KB0/38 Testing: py_test_tools_memleak
|
Enabling tracing in
We see a first probe hit for 30k, followed by another probe hit for 192k. The second one looks to be for
... we see just the one 30k allocation:
... and allows the test to pass. Perhaps the invocation of |
I looked at the test again. From the test case perspective, I think this patch is not needed even for powerpc with 64KB page. Basic the memleak tool does not really know what is the actually allocated memory size by the application/kernel. Sanitizer did more work to find real leaked size, but the memleak tool is pretty simple. It tracks the allocation with ptr and user-specified allocation size. If it does not see the ptr to be freed. It will report a leak with user-specified allocation size. |
The patch from @dubeyabhishek still looks relevant to me. I agree that the behavior is not necessarily related to 64k page size on powerpc, and more to do with how the memleak tool tracks [de-]allocations. However, the tool is also impacted by how libc implements The only alternative I can think of is to have the memleak tool ignore subsequent allocations. |
Could you modify the test to guard your change with powerpc architecture? Other arch should still use the original assert. Please also add a comment in the code. Thanks! |
1a97efc
to
ec981a5
Compare
9df63cc
to
118208a
Compare
Request to allocate 30K bytes using pvalloc(), results in allocating 3*64Kb(on 64Kb pagesize system). The assertion expects leak to be 30Kb, whereas leaked memory is much more due to pvalloc's implementation for power. Signed-off-by: Abhishek Dubey <[email protected]>
118208a
to
c2d9adf
Compare
Request to allocate 30K bytes to pvalloc(), results in allocating 3*64Kb in return. The test matches for leaked amount to be exactly equal to 30K bytes, whereas on system configured with 64Kb pagesize, leaked memory is much more than 30K bytes.