public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Possible endless loop in lto-wrapper
       [not found] <331707e8286fe9d5b7d3b5f0c83db4a7@213.92.108.204>
@ 2009-11-24 15:01 ` Rafael Espindola
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael Espindola @ 2009-11-24 15:01 UTC (permalink / raw)
  To: Leandro Nini; +Cc: gcc

> Hi Rafael,
>
> I'm sorry I cannot try the patch until next weekend.
> However, from a first look, it should work but I wonder: if the first
> maybe_unlink_file fails the others are never reached, leaving some
> temporary files in place. Is this ok?
>

Yes, I talked with Diego and he thinks that this is an unusual case
and it is better to just give up when the first unlink fails.

I have committed the patch, let me know if you see any issues.

> Thank you,
> Leandro
>  --
>  Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP
> autenticato? GRATIS solo con Email.it: http://www.email.it/f
>


Cheers,
-- 
Rafael Ávila de Espíndola

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Possible endless loop in lto-wrapper
  2009-11-23 19:00 ` Rafael Espindola
@ 2009-11-23 19:03   ` Diego Novillo
  0 siblings, 0 replies; 4+ messages in thread
From: Diego Novillo @ 2009-11-23 19:03 UTC (permalink / raw)
  To: Rafael Espindola; +Cc: Leandro Nini, gcc

On Mon, Nov 23, 2009 at 13:59, Rafael Espindola <espindola@google.com> wrote:

> 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.

OK.


Diego.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Possible endless loop in lto-wrapper
  2009-11-22  8:54 Leandro Nini
@ 2009-11-23 19:00 ` Rafael Espindola
  2009-11-23 19:03   ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael Espindola @ 2009-11-23 19:00 UTC (permalink / raw)
  To: Leandro Nini; +Cc: gcc

[-- 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);
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Possible endless loop in lto-wrapper
@ 2009-11-22  8:54 Leandro Nini
  2009-11-23 19:00 ` Rafael Espindola
  0 siblings, 1 reply; 4+ messages in thread
From: Leandro Nini @ 2009-11-22  8:54 UTC (permalink / raw)
  To: gcc

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.


Best Regards,
Leandro 
 --
 Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP
autenticato? GRATIS solo con Email.it: http://www.email.it/f
 
 Sponsor:
 Vinci subito fantastici premi, partecipando al gioco "alla faccia degli
amici" crea la faccia di chi vuoi tu e gioca!
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=9867&d=20091122


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-24 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <331707e8286fe9d5b7d3b5f0c83db4a7@213.92.108.204>
2009-11-24 15:01 ` Possible endless loop in lto-wrapper Rafael Espindola
2009-11-22  8:54 Leandro Nini
2009-11-23 19:00 ` Rafael Espindola
2009-11-23 19:03   ` Diego Novillo

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).