[llvm] r282433 - Allow StringRef to be constructed from a null pointer.

Evgenii Stepanov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 28 15:17:28 PDT 2016


It is starting to look like an Android bug. All functions in the stack
trace, up to __dl__start get a 16-byte aligned %esp on entry. As I
understand, it is supposed to be 16-aligned before the call, and
16-aligned minus 4 on function entry.

I'll take care of it.


On Wed, Sep 28, 2016 at 3:03 PM, Zachary Turner <zturner at google.com> wrote:
> Who is the best person to look at this?  It sounds like a codegen bug of
> some kind.  I assume it's using an llvm toolchain?
>
> On Wed, Sep 28, 2016 at 2:58 PM Evgenii Stepanov <eugeni.stepanov at gmail.com>
> wrote:
>>
>> Stack trace:
>> #0  0xb74b3850 in _GLOBAL__sub_I_DiagnosticInfo.cpp () at
>> /code/llvm/include/llvm/Support/CommandLine.h:291
>> #1  0xb747acd7 in __dl__ZN6soinfo16CallConstructorsEv.part.10 () from
>> z/system/bin/linker
>> #2  0xb747df8f in
>> __dl__ZL29__linker_init_post_relocationR19KernelArgumentBlockj () from
>> z/system/bin/linker
>> #3  0xb74808c8 in __dl___linker_init () from z/system/bin/linker
>> #4  0xb7481704 in __dl__start () from z/system/bin/linker
>> #5  0x00000001 in ?? ()
>>
>> Source:
>> 291  void setDescription(StringRef S) { HelpStr = S; }
>>
>> Asm:
>> => 0xb74b3850 <+480>: movdqa %xmm2,0x40(%esp)
>>
>> This is an unaligned load. Your change must have triggered a bug in
>> some other code.
>>
>>
>> On Wed, Sep 28, 2016 at 2:49 PM, Zachary Turner <zturner at google.com>
>> wrote:
>> > Sorry, I take that back.  If this change had any effect on existing
>> > code,
>> > then llvm-symbolizer should have been asserting before my patch
>> >
>> > On Wed, Sep 28, 2016 at 2:47 PM Zachary Turner <zturner at google.com>
>> > wrote:
>> >>
>> >> That is quite surprising, I admit I haven't seen the stack trace, but
>> >> I'm
>> >> inclined to say that something is wrong with the bisection method.  The
>> >> only
>> >> thing this change could possibly do is allow an object to be
>> >> constructed
>> >> where previously a construction would have failed to compile.  So if
>> >> this
>> >> change had any effect on existing code, then llvm-symbolizer shouldn't
>> >> have
>> >> even been compiling before.
>> >>
>> >> On Wed, Sep 28, 2016 at 2:36 PM Evgenii Stepanov
>> >> <eugeni.stepanov at gmail.com> wrote:
>> >>>
>> >>> This change broke llvm-symbolizer on android/x86 (and only x86), SEGV
>> >>> at startup. Trying to get a stack trace...
>> >>>
>> >>> On Mon, Sep 26, 2016 at 1:08 PM, Zachary Turner via llvm-commits
>> >>> <llvm-commits at lists.llvm.org> wrote:
>> >>> > Author: zturner
>> >>> > Date: Mon Sep 26 15:08:05 2016
>> >>> > New Revision: 282433
>> >>> >
>> >>> > URL: http://llvm.org/viewvc/llvm-project?rev=282433&view=rev
>> >>> > Log:
>> >>> > Allow StringRef to be constructed from a null pointer.
>> >>> >
>> >>> > Differential Revision: https://reviews.llvm.org/D24904
>> >>> >
>> >>> > Modified:
>> >>> >     llvm/trunk/include/llvm/ADT/StringRef.h
>> >>> >
>> >>> > Modified: llvm/trunk/include/llvm/ADT/StringRef.h
>> >>> > URL:
>> >>> >
>> >>> > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=282433&r1=282432&r2=282433&view=diff
>> >>> >
>> >>> >
>> >>> > ==============================================================================
>> >>> > --- llvm/trunk/include/llvm/ADT/StringRef.h (original)
>> >>> > +++ llvm/trunk/include/llvm/ADT/StringRef.h Mon Sep 26 15:08:05 2016
>> >>> > @@ -73,14 +73,14 @@ namespace llvm {
>> >>> >      /// Construct an empty string ref.
>> >>> >      /*implicit*/ StringRef() : Data(nullptr), Length(0) {}
>> >>> >
>> >>> > +    /// Disable conversion from nullptr.  This prevents things like
>> >>> > +    /// if (S == nullptr)
>> >>> >      StringRef(std::nullptr_t) = delete;
>> >>> >
>> >>> >      /// Construct a string ref from a cstring.
>> >>> > +    LLVM_ATTRIBUTE_ALWAYS_INLINE
>> >>> >      /*implicit*/ StringRef(const char *Str)
>> >>> > -      : Data(Str) {
>> >>> > -        assert(Str && "StringRef cannot be built from a NULL
>> >>> > argument");
>> >>> > -        Length = ::strlen(Str); // invoking strlen(NULL) is
>> >>> > undefined
>> >>> > behavior
>> >>> > -      }
>> >>> > +        : Data(Str), Length(Str ? ::strlen(Str) : 0) {}
>> >>> >
>> >>> >      /// Construct a string ref from a pointer and length.
>> >>> >      LLVM_ATTRIBUTE_ALWAYS_INLINE
>> >>> >
>> >>> >
>> >>> > _______________________________________________
>> >>> > llvm-commits mailing list
>> >>> > llvm-commits at lists.llvm.org
>> >>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list