[Lldb-commits] [lldb] r316740 - Fix a use-after-free in lldb-server

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 31 08:19:46 PDT 2017


On 31 October 2017 at 15:12, Zachary Turner via lldb-commits
<lldb-commits at lists.llvm.org> wrote:
> The takeaway from this example is nothing we don't already know.  We need
> better test coverage.
Actually, this was caught by a test (pretty much all of them), but
only when building with libc++, as the code was "safe" with libstdc++
due to the copy-on-write implementation of std::string (the temporary
object shared storage with the longer-lived string it was copied
from).

>
> On Tue, Oct 31, 2017 at 8:08 AM Greg Clayton via lldb-commits
> <lldb-commits at lists.llvm.org> wrote:
>>
>> This is one example of how StringRef causes issues because it was adopted
>> everywhere. Is there any way we can change our functions so we can't run
>> into this issue? Anything we can learn from this example?

My takeaway from this is to be more careful when returning StringRef
objects from a function. The patch in question changed the lifetime
semantics of UrlParser. Unlike most other const char * -> StringRef
conversions, this is kind of change requires a closer look at the
existing callers to make sure they satisfy the new constraints.


More information about the lldb-commits mailing list