This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Possible endless loop in lto-wrapper
- From: Rafael Espindola <espindola at google dot com>
- To: Leandro Nini <drfiemost at email dot it>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 23 Nov 2009 13:59:55 -0500
- Subject: Re: Possible endless loop in lto-wrapper
- References: <230dad3a0c3b3643ffa3d7e36453e8bf@95.235.216.248>
2009/11/22 Leandro Nini <drfiemost@email.it>:
> Hi,
>
> in gcc-4.5 lto-wrapper may end up in an endless loop in case of error:
>
> if for example a 'maybe_unlink_file' call from 'lto_wrapper_exit' fails it
> calls 'fatal_perror' which in turn calls 'lto_wrapper_exit' again causing
> an infinity of
>
> lto-wrapper: deleting LTRANS file /tmp/ccWjXUv8.lto.o: No such file or
> directory
>
> error messages on the console.
>
> I've solved this by substituting 'maybe_unlink_file' with
> 'unlink_if_ordinary'
> whithin the 'lto_wrapper_exit' function.
> Not sure if this is the best fix but hope it helps.
Thanks for finding the bug!
I think that we need something similar to what was done in the linker:
Avoid trying to start a new cleanup if we are already in one.
Leandro, can you try the attached patch?
Diego, OK if it works?
2009-11-23 Rafael Avila de Espindola <espindola@google.com>
* lto-wrapper.c (lto_wrapper_exit): Don't try to delete files if
being called recursively.
>
> Best Regards,
> Leandro
> Â--
Cheers,
--
Rafael Ãvila de EspÃndola
Index: gcc/lto-wrapper.c
===================================================================
--- gcc/lto-wrapper.c (revision 154452)
+++ gcc/lto-wrapper.c (working copy)
@@ -66,12 +66,20 @@
static void
lto_wrapper_exit (int status)
{
- if (ltrans_output_file)
- maybe_unlink_file (ltrans_output_file);
- if (flto_out)
- maybe_unlink_file (flto_out);
- if (args_name)
- maybe_unlink_file (args_name);
+ static bool cleanup_done = false;
+ if (!cleanup_done)
+ {
+ /* Setting cleanup_done prevents an infinite loop if one of the
+ calls to maybe_unlink_file fails. */
+ cleanup_done = true;
+
+ if (ltrans_output_file)
+ maybe_unlink_file (ltrans_output_file);
+ if (flto_out)
+ maybe_unlink_file (flto_out);
+ if (args_name)
+ maybe_unlink_file (args_name);
+ }
exit (status);
}