[llvm] r223306 - Move tests for llvm-objdump for universal files to X86 directory to fix build bots.

Kevin Enderby enderby at apple.com
Wed Dec 3 18:26:25 PST 2014


Hi Rafael,

I don’t use cmake and I even when I added -fsanitize=address directly to the command I still had problems.  The clang on the system didn’t take it and when I switched to using the just built top of tree clang it got an error not finding <algorithm> .  I suspect I don’t have the set up needed for asan.

But looking at your asan diagnostic I think the problem in my code is the assignment of ArchitectureName which is a StringRef that later has the problem.  It is assigned the std::string returned by MachOUniversalBinary::getArchTypeName().  Which is this line (line 421 which is where your as an diagnostic said it was allocated):

	ArchitectureName = I->getArchTypeName();

I think the fix is to change the type of ArchitectureName to a std::string from a StringRef with this diff:

*** previous_MachODump.cpp	2014-12-03 18:07:14.000000000 -0800
--- MachODump.cpp	2014-12-03 18:06:34.000000000 -0800
***************
*** 416,422 ****
           I != E; ++I) {
        ErrorOr<std::unique_ptr<ObjectFile>> ObjOrErr = I->getAsObjectFile();
        std::unique_ptr<Archive> A;
!       StringRef ArchitectureName = StringRef();
        if (moreThanOneArch)
          ArchitectureName = I->getArchTypeName();
        if (ObjOrErr) {
--- 416,422 ----
           I != E; ++I) {
        ErrorOr<std::unique_ptr<ObjectFile>> ObjOrErr = I->getAsObjectFile();
        std::unique_ptr<Archive> A;
!       std::string ArchitectureName = "";
        if (moreThanOneArch)
          ArchitectureName = I->getArchTypeName();
        if (ObjOrErr) {

Does that look right to you?  Pretty sure that is what Jim suggested but he is gone for the evening now.  I’ll take this up tomorrow.

Kev

On Dec 3, 2014, at 4:49 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:

> On 3 December 2014 at 19:46, Kevin Enderby <enderby at apple.com> wrote:
>> I don’t have asan set up.  But I can work with Jim to help me with that or if you can point me to some instructions I’ll give that a go tonight.
> 
> You will need a host compiler with a resent compiler-rt build. After
> that it should be enough to just add -DLLVM_USE_SANITIZER=Address to
> the cmake invocation.
> 
> It is awesome :-)
> 
> Cheers,
> Rafael





More information about the llvm-commits mailing list