[LLVMdev] Making LLVM safer in out-of-memory situations
Philip Reames
listmail at philipreames.com
Thu Dec 19 09:40:01 PST 2013
On 12/13/13 6:47 AM, Becker, Philipp wrote:
> Hi Hal,
>
>> Does this mean that you're using C++ exception handling to manage the cleanup?
> No, not really. From the place where we're calling into llvm we are catching all exceptions that may occur during compilation, but normally we do not add any additional catch clauses into the llvm source itself. We mainly rely on correct stack unwinding by destructors in llvm when an exception is thrown. In the cases when it is not sufficient, we had to add some additional autopointers, an in some cases implement additional unwind logic. In some cases we indeed had to add some exception handling in destructors in cases where they allocate memory, but such fixes are rather workarounds, because a correct solution would be to avoid memory allocation in destructors in the first place.
If I'm reading you correctly, you are relying on exception propagation
and handler (destructors for local objects) execution. You have chosen
not to add extra exception logic to LLVM itself, but are relying on the
correctness of exception propagation within the code. (The last two
sentances are intended to be a restatement of what your message said.
If I misunderstood, please correct me.)
Does this mean that you're compiling your build of LLVM with exceptions
enabled? By default, I believe LLVM is built without RTTI or exception
support.
For the particular cases you mentioned with auto pointers and allocation
in destructors, are these issues also present along existing error
paths? Or for that matter simply examples of bad coding practice? If
so, pushing back selected changes would be welcomed. I'd be happy to
help review.
Philip
More information about the llvm-dev
mailing list