Fix clang cc1as crash for asm output
Steven Wu
stevenwu at apple.com
Thu Jul 23 18:43:31 PDT 2015
> On Jul 23, 2015, at 5:15 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
>
>
> On 23 July 2015 at 18:03, Steven Wu <stevenwu at apple.com <mailto: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?
Seems like it. I am just guessing. I am not trying to blame anyone but rather to get someone’s attention for code review.
> Is there a test we can add? Even one that would only fail when
> building with the sanitizers would be fine.
It was actually crashing pretty consistently and you don’t need to have a sanitizer to notice that. No one ever noticed probably because clang driver will not generate this combination of the arguments. I will add a test case just so it will exercise the code path.
Thanks
Steven
>
> With that, LGTM.
>
> Cheers,
> Rafael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150723/67776ad0/attachment.html>
More information about the cfe-commits
mailing list