[cfe-dev] llvm::CrashRecoveryContext (in libclang)
Vedant Kumar via cfe-dev
cfe-dev at lists.llvm.org
Thu Oct 1 10:40:07 PDT 2015
> On Sep 27, 2015, at 8:13 PM, John Sully via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> I'm writing a client application that uses libclang and uses it to parse documents on multiple threads. I've been debugging a memory corruption bug and traced it to the CrashRecoveryContext destructor deleting other thread's Parser objects out from under it.
>
> Looking at the CrashRecoveryContext code it appears no effort is made to make this thread safe, specifically it heavily relies on static members which is how pointers are making their way across threads.
>
> There are two questions here:
> 1) Is libclang intended to be thread safe? (I.e. would a patch be accepted to fix this or is this behavior by design)
I'd be very happy to see patches geared towards making libclang more thread safe. There seem to be important use cases for this.
> 2) Generally "recovering" from unknown crashes is considered to be bad practice, is there a recommended way to prevent use of the crash recovery mechanism?
The clang driver uses process isolation. E.g, a monitor process can wait on the compile process and emit diagnostics if it crashes. Does that work for your project?
vedant
More information about the cfe-dev
mailing list