[LLVMdev] gcc bug?..segfault problem with getElfArchType.

Michael Spencer bigcheesegs at gmail.com
Sat Jun 30 18:31:46 PDT 2012


On Sat, Jun 30, 2012 at 5:40 PM, Sid Manning <sidneym at codeaurora.org> wrote:
> On 06/30/2012 07:16 PM, Michael Spencer wrote:
>>
>> On Sat, Jun 30, 2012 at 7:58 AM, Sid Manning<sidneym at codeaurora.org>
>>  wrote:
>>>
>>>
>>> I've been debugging a segfault issue with the elfreader and I would like
>>> to
>>> point out something that I have noticed.
>>>
>>> ELF.h declares an inline function, getElfArchType (MemoryBuffer *Object).
>>>  When this function is called from ObjectFile::createELFObjectFile the
>>> pointer to Object was getting corrupted.  The only thing that
>>> distinguished
>>> this pointer was that it was declared as a unique_ptr.  The flow from
>>> when
>>> it was created to getElfArchType is pretty direct.
>>>
>>> The segfault only happens only at optimization level -O0.
>>> The segfault doesn't happen if getElfArchType is declared as, "static
>>> inline"
>>
>>
>> Is this occurring with ELF.h in lld? If so this sounds like your
>> compiling llvm and lld with different standard libraries and because
>> -O0 doesn't inline, the linkonce linkage is picking the wrong one.
>
>
> Yes, this is happening with ELF.h in lld; so that may be what is happening.
>  I'm testing ReaderELF.h with a version of lld-core that reads objects
> rather than YAML.
>
> What is the fix, build everything with std=c++0x?
>
> Thanks,
>

Everything has to be compiled with -std=c++11 (or 0x if you are using
an ancient compiler) and -stdlib=libc++ if using clang, unless
compatibility has recently changed with libstdc++.

- Michael Spencer




More information about the llvm-dev mailing list