Fix clang cc1as crash for asm output

Rafael Espíndola rafael.espindola at gmail.com
Thu Jul 23 17:15:33 PDT 2015


On 23 July 2015 at 18:03, Steven Wu <stevenwu at apple.com> wrote:
> Hi Rafael
>
> This looks like a fallout from your ostream rewrite. In clang cc1as_main, when the output file type is “asm”, AsmStreamer owns a formatted_raw_ostream which has a reference to FDOS (raw_ostream), so AsmStreamer must be closed before FDOS. Here is the patch.
>
> Thanks
> Steven
>
> From f930e3d8a8c7da74de6000bb3b80f90efc5615ff Mon Sep 17 00:00:00 2001
> From: Steven Wu <stevenwu at apple.com>
> Date: Thu, 23 Jul 2015 14:48:24 -0700
> Subject: [PATCH 1/2] Fix the cc1as crash when it outputs assembly
>
> ---
>  tools/driver/cc1as_main.cpp | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp
> index aa92541..fd0fbb4 100644
> --- a/tools/driver/cc1as_main.cpp
> +++ b/tools/driver/cc1as_main.cpp
> @@ -406,6 +406,9 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
>      Failed = Parser->Run(Opts.NoInitialTextSection);
>    }
>
> +  // Close Streamer first.
> +  // It might have a reference to the output stream.
> +  Str.reset();

it always has a reference, no?

Is there a test we can add? Even one that would only fail when
building with the sanitizers would be fine.

With that, LGTM.

Cheers,
Rafael




More information about the cfe-commits mailing list