From: Rafael Espindola <espindola@google.com>
To: Leandro Nini <drfiemost@email.it>
Cc: gcc@gcc.gnu.org
Subject: Re: Possible endless loop in lto-wrapper
Date: Mon, 23 Nov 2009 19:00:00 -0000 [thread overview]
Message-ID: <38a0d8450911231059t29d1aa81u72072b5f52ae93c@mail.gmail.com> (raw)
In-Reply-To: <230dad3a0c3b3643ffa3d7e36453e8bf@95.235.216.248>
[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]
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
[-- Attachment #2: clean.patch --]
[-- Type: text/x-diff, Size: 861 bytes --]
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);
}
next prev parent reply other threads:[~2009-11-23 19:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-22 8:54 Leandro Nini
2009-11-23 19:00 ` Rafael Espindola [this message]
2009-11-23 19:03 ` Diego Novillo
[not found] <331707e8286fe9d5b7d3b5f0c83db4a7@213.92.108.204>
2009-11-24 15:01 ` Rafael Espindola
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=38a0d8450911231059t29d1aa81u72072b5f52ae93c@mail.gmail.com \
--to=espindola@google.com \
--cc=drfiemost@email.it \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).