Skip to content
Back to formatted view

Raw Message

Message-ID: <bd2d1667-75ca-f745-548d-ad15f96e41fb@gmail.com>
Date: 2021-03-12T17:37:00Z
From: Duncan Murdoch
Subject: R extension memory leak detection question
In-Reply-To: <CANjVfJ1mAeXDLp43nYrtEoKFiqP-4xpc17nz4XYuNaY8qQw+_A@mail.gmail.com>

On 12/03/2021 12:13 p.m., xiaoyan yu wrote:
> I am writing C++ program based on R extensions and also try to test the
> program with google address sanitizer.
> 
> I thought if we don't protect the variable from the allocation API such as
> Rf_allocVector, there will be a memory leak. However, the address sanitizer
> didn't report it. Is my understanding correct? Or I will see the memory
> leak only if I compile R source code with the address sanitizer.
> 

Your question is unclear without an actual example.  It all depends on 
how the variable was created and how you use it.

If your real code is only a few lines, post it here.  Otherwise, please 
put together a minimal working example that contains the essence of what 
you are doing in a few lines.  Check that it compiles, and we can 
provide advice about whether it is doing dangerous things.

Duncan Murdoch