Quit Application Error.

Hi when I run line Clang.ExecuteAction(*Act), when i quit my
application, it throws an error saying "Virtual Function Call"..

It only throws this error when the line gets called and later I quit
my app. Ive narrowed it down to this line being called.

Any ideas?

I am using llvm::llvm_shutdown().

Thanks.

Are you sure you didn't mess up the object ownership somewhere?
Trying to delete an already-freed object could easily cause an error
like that.

-Eli

Ni im not deleting anything, Im running each instance of clang in it's
own thread, when I want to quit the app, the thread calles
llvm::llvm_shutdown() and exits.

Even if theres only one instance of clang running, it throws an error
when I quit.

Paul Griffiths <gafferuk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
writes:

Ni im not deleting anything, Im running each instance of clang in it's
own thread, when I want to quit the app, the thread calles
llvm::llvm_shutdown() and exits.

Even if theres only one instance of clang running, it throws an error
when I quit.

IIUC the ownership patterns in Diagnostic changed relatively recently,
so (for example) the clang-interpreter is incorrect. Currently it has:

  TextDiagnosticPrinter DiagClient(llvm::errs(), DiagnosticOptions());

  Diagnostic Diags(&DiagClient);

I think this should now be something like

  TextDiagnosticPrinter* DiagClient = new TextDiagnosticPrinter(llvm::errs(), DiagnosticOptions());

  Diagnostic Diags(DiagClient);

i.e., the destructor for Diagnostic will attempt to delete DiagClient
which might well be the crash you're seeing?

[...]

no, still happens.

I have more info on the crash.
It's in raw_ostream.cpp at function:
raw_ostream &raw_ostream::write(const char *Ptr, size_t Size)

5th line:
write_impl(Ptr, Size);

any ideas?

I have more info on the crash.
It's in raw_ostream.cpp at function:
raw_ostream &raw_ostream::write(const char *Ptr, size_t Size)

5th line:
write_impl(Ptr, Size);

any ideas?

It sounds like the raw_ostream is destroyed, then something is continuing to try to write on it.

-Chris