How to use address sanitizer on a sub process

3,694 views
Skip to first unread message

Seshadri R

unread,
May 21, 2018, 12:01:31 PM5/21/18
to address-sanitizer
Hi,

I want to use address sanitizer to profile a program (say A). However, this program is launched as a child of another process (B). I have built the executable for A using the compiler flags :
-fsanitize=address -static-libasan

 and linked the process using the flags 
-fsanitize=address -static-libasan -lasan.

However, when I launch Process A as a subprocess of process B, I am not getting any errors or warnings. 

How do I get the memory leaks in process A using Address Sanitizer?

Thanks and Regards
Seshadri 

Konstantin Serebryany

unread,
May 21, 2018, 12:24:42 PM5/21/18
to address-sanitizer
On Mon, May 21, 2018 at 9:01 AM Seshadri R <seshad...@gmail.com> wrote:
Hi,

I want to use address sanitizer to profile a program (say A). However, this program is launched as a child of another process (B). I have built the executable for A using the compiler flags :
-fsanitize=address -static-libasan

 and linked the process using the flags 
-fsanitize=address -static-libasan -lasan.

You should never need -lasan. 
If any piece of documentation tells you to use -lasan, please let us know, we need to remove that. 

-fsanitize=address at both compile and link-time should be sufficient.  
-static-libasan is optional. 

 

However, when I launch Process A as a subprocess of process B, I am not getting any errors or warnings. 

Maybe your program doesn't have bugs? 
 

How do I get the memory leaks in process A using Address Sanitizer?

Are you only looking for memory leaks or for other types of bugs too?
Unlike most other kinds of bugs, memory leaks are reported when the process is exiting, 
 

Thanks and Regards
Seshadri 

--
You received this message because you are subscribed to the Google Groups "address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to address-saniti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yuri Gribov

unread,
May 21, 2018, 12:54:42 PM5/21/18
to address-...@googlegroups.com
On Mon, May 21, 2018 at 5:24 PM, Konstantin Serebryany
<konstantin....@gmail.com> wrote:
>
>
> On Mon, May 21, 2018 at 9:01 AM Seshadri R <seshad...@gmail.com> wrote:
>>
>> Hi,
>>
>> I want to use address sanitizer to profile a program (say A). However,
>> this program is launched as a child of another process (B). I have built the
>> executable for A using the compiler flags :
>> -fsanitize=address -static-libasan
>>
>> and linked the process using the flags
>> -fsanitize=address -static-libasan -lasan.
>
>
> You should never need -lasan.
> If any piece of documentation tells you to use -lasan, please let us know,
> we need to remove that.

Most people pick it up from stackoverflow or blogposts...

Seshadri R

unread,
May 22, 2018, 6:25:07 AM5/22/18
to address-...@googlegroups.com
Hi Konstantin,

Thanks for your reply.

The programs makefile has those options (maintained by our build team) and I mentioned them to provide complete information. 

Coming back to my question, I have tried to introduce a memory leak by adding the following code: 

    int * pp = new int[1000000000];
    pp = 0;

Even then I did not get any memory leak reported. Is there any other way I can introduce a memory leak to check that my application is built properly and catching memory leaks.

Thanks and Regards
Seshadri R


To unsubscribe from this group and stop receiving emails from it, send an email to address-sanitizer+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to address-sanitizer+unsubscribe@googlegroups.com.

Konstantin Serebryany

unread,
May 31, 2018, 2:10:58 PM5/31/18
to address-sanitizer
On Tue, May 22, 2018 at 3:25 AM Seshadri R <seshad...@gmail.com> wrote:
Hi Konstantin,

Thanks for your reply.

The programs makefile has those options (maintained by our build team) and I mentioned them to provide complete information. 

Coming back to my question, I have tried to introduce a memory leak by adding the following code: 

    int * pp = new int[1000000000];
    pp = 0;

In this code a memory leak is likely to be optimized away by the compiler -- you may check the resulting object file and most likely you won't see a leak. 
Try a test where the compiler won't remove the call no 'new'
 

Even then I did not get any memory leak reported. Is there any other way I can introduce a memory leak to check that my application is built properly and catching memory leaks.

Thanks and Regards
Seshadri R

On Mon, May 21, 2018 at 9:54 PM, Konstantin Serebryany <konstantin....@gmail.com> wrote:
On Mon, May 21, 2018 at 9:01 AM Seshadri R <seshad...@gmail.com> wrote:
Hi,

I want to use address sanitizer to profile a program (say A). However, this program is launched as a child of another process (B). I have built the executable for A using the compiler flags :
-fsanitize=address -static-libasan

 and linked the process using the flags 
-fsanitize=address -static-libasan -lasan.

You should never need -lasan. 
If any piece of documentation tells you to use -lasan, please let us know, we need to remove that. 

-fsanitize=address at both compile and link-time should be sufficient.  
-static-libasan is optional. 

 

However, when I launch Process A as a subprocess of process B, I am not getting any errors or warnings. 

Maybe your program doesn't have bugs? 
 

How do I get the memory leaks in process A using Address Sanitizer?

Are you only looking for memory leaks or for other types of bugs too?
Unlike most other kinds of bugs, memory leaks are reported when the process is exiting, 

Thanks and Regards
Seshadri 

--
You received this message because you are subscribed to the Google Groups "address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to address-saniti...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to address-saniti...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to address-saniti...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages