This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: GCC EH unwinding bug and libjava calling std::terminate ()
- From: Andrew Haley <aph at redhat dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc at gcc dot gnu dot org, java at gcc dot gnu dot org
- Date: Fri, 27 Mar 2009 13:10:53 +0000
- Subject: Re: GCC EH unwinding bug and libjava calling std::terminate ()
- References: <20090327123754.GA24355@kam.mff.cuni.cz>
Jan Hubicka wrote:
> current mainline is buggy in EH unwinding effectivly ignoring
> MUST_NOT_THROW regions when reached via RESX from local handlers.
> See http://gcc.gnu.org/ml/gcc-patches/2009-03/msg01285.html for details.
>
> Unfortunately this patch causes bootstrap failure when building libjava,
> because std::terminate() is now called. The call comes from
> run_proxy in natVMProxy.cc where we have cleanup code calling
> destructor of:
>
> _Jv_InterpFrame frame_desc (self->self, thread, proxyClass,
> NULL, frame_proxy);
>
> Now the desctuctor is pretty simple but because of:
> 'if a destructor called during stack unwinding exits with an exception,
> std::terminate is called'
>
> and because we use -fnon-call-excpetion and destructor is accessing
> memory, we keep MUST_NOT_THROW terminate () call accessible
> because after inlining the destructor, cleanup might unwind up
> to that MUST_NOT_THROW.
>
> Questio is how to fix this situation? Shall we link with C++ runtime,
Please don't.
> or use -fno-non-call-exceptions
No, because it might segfault, and we need to catch it.
> to build this file or somehow restruture
> code to avoid this case?
/* Gimplify a MUST_NOT_THROW_EXPR. */
static enum gimplify_status
gimplify_must_not_throw_expr (tree *expr_p, gimple_seq *pre_p)
{
tree stmt = *expr_p;
tree temp = voidify_wrapper_expr (stmt, NULL);
tree body = TREE_OPERAND (stmt, 0);
tree termination;
if (pragma_java_exceptions)
termination = terminate_node;
else
termination = abort_node;
stmt = build_gimple_eh_filter_tree (body, NULL_TREE,
build_call_n (termination, 0));
Andrew.