Skip to content
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

Can't get leak details #45

Open
hellotommmy opened this issue Oct 19, 2021 · 8 comments
Open

Can't get leak details #45

hellotommmy opened this issue Oct 19, 2021 · 8 comments
Labels
10.15 bug Something isn't working

Comments

@hellotommmy
Copy link

hellotommmy commented Oct 19, 2021

On my mac with os version 10.15.7 (19H1323),
I could not get details of a leak, only leak summary is available.
A minimum example would be

#include <iostream>

int main(){
        int * p = (int *) malloc(10);
        std::cout << "memory leak in main\n";
        return 0;
}

If I compile this with
g++ -std=c++11 -o simple -g simple.cpp
And run
valgrind ./simple
I got

==85050== Memcheck, a memory error detector
==85050== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==85050== Using Valgrind-3.18.0.GIT-lbmacos and LibVEX; rerun with -h for copyright info
==85050== Command: ./simple
==85050== 
memory leak in main
==85050== 
==85050== HEAP SUMMARY:
==85050==     in use at exit: 18,084 bytes in 164 blocks
==85050==   total heap usage: 178 allocs, 14 frees, 22,828 bytes allocated
==85050== 
==85050== LEAK SUMMARY:
==85050==    definitely lost: 10 bytes in 1 blocks
==85050==    indirectly lost: 0 bytes in 0 blocks
==85050==      possibly lost: 0 bytes in 0 blocks
==85050==    still reachable: 4,096 bytes in 1 blocks
==85050==         suppressed: 13,978 bytes in 162 blocks
==85050== Rerun with --leak-check=full to see details of leaked memory
==85050== 
==85050== For lists of detected and suppressed errors, rerun with: -s
==85050== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1)

And adding the --leak-check=full flag does not help. --track-origins=yes does not help either.
Am I missing something?
Thanks a lot for your work!

@LouisBrunner
Copy link
Owner

Which version of Xcode are you using?

@LouisBrunner LouisBrunner added 10.15 bug Something isn't working labels Nov 12, 2021
@hellotommmy
Copy link
Author

Which version of Xcode are you using?

I am not using Xcode, just plain terminal command line.

@ctrlpz
Copy link

ctrlpz commented Nov 16, 2021

Hello,
I think I have the same issue. I have installed Valgrind in MacOS Big Sur (11.6.1) and when I run this code in the command line

`#include <stdlib.h>

void f(void)
{
int* x = malloc(10 * sizeof(int));
x[10] = 0; // problem 1: heap block overrun
} // problem 2: memory leak -- x not freed

int main(void)
{
f();
return 0;
}`

I do not get the expected memory leaks, but the following output:
==36229== Memcheck, a memory error detector ==36229== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==36229== Using Valgrind-3.18.0.GIT-lbmacos and LibVEX; rerun with -h for copyright info ==36229== Command: /Users/carmentorres/Documents/Academy/Postdoc/Strructuur2/Memcheck/examples/output2 ==36229== ==36229== Warning: set address range perms: large range [0x7fff20200000, 0x800020000000) (defined) ==36229== Warning: set address range perms: large range [0x7fff20200000, 0x7fff7ffdc000) (defined) ==36229== Warning: set address range perms: large range [0x7fff8e47c000, 0x7fffc0200000) (noaccess) ==36229== Warning: set address range perms: large range [0x7fffc0200000, 0x7fffe30c4000) (defined) ==36229== Warning: set address range perms: large range [0x7fffe30c4000, 0x7fffffe00000) (noaccess) ==36229== ==36229== HEAP SUMMARY: ==36229== in use at exit: 0 bytes in 0 blocks ==36229== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==36229== ==36229== All heap blocks were freed -- no leaks are possible ==36229== ==36229== For lists of detected and suppressed errors, rerun with: -s ==36229== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

I used this command for run it: "valgrind --leak-check=yes myprogram".
Please, could you tell me if I'm missing something or is this a bug?

Thank you in advanced,
Carmen

@LouisBrunner
Copy link
Owner

@ctrlpz Big Sur is not supported at the moment (#19)

@hellotommmy You are still using Xcode to build your binary (unless you have explicitly replaced it with an actual gcc which is unlikely and in which case you are still using Xcode for system libraries)
If you run xcodebuild -version and sw_vers and give me the result I might be able to help

@hellotommmy
Copy link
Author

@ctrlpz Big Sur is not supported at the moment (#19)

@hellotommmy You are still using Xcode to build your binary (unless you have explicitly replaced it with an actual gcc which is unlikely and in which case you are still using Xcode for system libraries) If you run xcodebuild -version and sw_vers and give me the result I might be able to help

Sorry about that--I didn't know.

Running xcodebuild -version gives me
Xcode 12.3
Build version 12C5020f

and sw_vers gives me
ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H1323

Thanks you :)

@LouisBrunner
Copy link
Owner

@hellotommmy That's no worries at all, I just wanted to make sure if you weren't using another compiler somehow :)

This is a bit odd, it might just be how we check the Xcode/kernel version but it looks like Xcode 12 should be fine (?)

@hellotommmy
Copy link
Author

@hellotommmy That's no worries at all, I just wanted to make sure if you weren't using another compiler somehow :)

This is a bit odd, it might just be how we check the Xcode/kernel version but it looks like Xcode 12 should be fine (?)

Is there a way I could change to a different compiler and hopefully see different results?

@LouisBrunner
Copy link
Owner

If you could get a earlier version of Xcode I think it might work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.15 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants