diff mbox

Diagnostics from GCC_DRIVER_HOST_INITIALIZATION

Message ID 5008788E.6000306@qnx.com
State New
Headers show

Commit Message

Ryan Mansfield July 19, 2012, 9:13 p.m. UTC
GCC_DRIVER_HOST_INITIALIZATION happens before diagnostic_initialize, 
this can cause crashes if it call diagnostics such as warning, or 
fatal_error are used in the macro. One example would be in 
darwin-driver.c where darwin_find_version_from_kernel can call 
warning(). Another example is in xm-djgpp.h where it calls fatal (this 
appears to have bit-rotted with the fatal -> fatal_error switch)

Would moving the GCC_DRIVER_HOST_INITIALIZATION after 
diagnostic_initialize be OK?


Regards,

Ryan Mansfield

Comments

Gabriel Dos Reis July 19, 2012, 10:06 p.m. UTC | #1
On Thu, Jul 19, 2012 at 4:13 PM, Ryan Mansfield <rmansfield@qnx.com> wrote:
> GCC_DRIVER_HOST_INITIALIZATION happens before diagnostic_initialize, this
> can cause crashes if it call diagnostics such as warning, or fatal_error are
> used in the macro. One example would be in darwin-driver.c where
> darwin_find_version_from_kernel can call warning(). Another example is in
> xm-djgpp.h where it calls fatal (this appears to have bit-rotted with the
> fatal -> fatal_error switch)
>
> Would moving the GCC_DRIVER_HOST_INITIALIZATION after diagnostic_initialize
> be OK?

yes, I think so.

>
> Index: gcc.c
> ===================================================================
> --- gcc.c       (revision 189681)
> +++ gcc.c       (working copy)
> @@ -6189,17 +6189,18 @@
>                                    CL_DRIVER,
>                                    &decoded_options,
> &decoded_options_count);
>
> -#ifdef GCC_DRIVER_HOST_INITIALIZATION
> -  /* Perform host dependent initialization when needed.  */
> -  GCC_DRIVER_HOST_INITIALIZATION;
> -#endif
> -
>    /* Unlock the stdio streams.  */
>    unlock_std_streams ();
>
>    gcc_init_libintl ();
>
>    diagnostic_initialize (global_dc, 0);
> +
> +#ifdef GCC_DRIVER_HOST_INITIALIZATION
> +  /* Perform host dependent initialization when needed.  */
> +  GCC_DRIVER_HOST_INITIALIZATION;
> +#endif
> +
>    if (atexit (delete_temp_files) != 0)
>      fatal_error ("atexit failed");
>
>
> Regards,
>
> Ryan Mansfield
diff mbox

Patch

Index: gcc.c
===================================================================
--- gcc.c	(revision 189681)
+++ gcc.c	(working copy)
@@ -6189,17 +6189,18 @@ 
  				   CL_DRIVER,
  				   &decoded_options, &decoded_options_count);

-#ifdef GCC_DRIVER_HOST_INITIALIZATION
-  /* Perform host dependent initialization when needed.  */
-  GCC_DRIVER_HOST_INITIALIZATION;
-#endif
-
    /* Unlock the stdio streams.  */
    unlock_std_streams ();

    gcc_init_libintl ();

    diagnostic_initialize (global_dc, 0);
+
+#ifdef GCC_DRIVER_HOST_INITIALIZATION
+  /* Perform host dependent initialization when needed.  */
+  GCC_DRIVER_HOST_INITIALIZATION;
+#endif
+
    if (atexit (delete_temp_files) != 0)
      fatal_error ("atexit failed");