Opened 12 years ago

Closed 11 years ago

#36490 closed defect (fixed)

cctools: lipo assertion failure and crash

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: jeremyhu (Jeremy Huddleston Sequoia)
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: Cc:
Port: llvm-3.1

Description

lipo is crashing again with an assertion failure on certain input files (files less than 4 bytes long). This is like #36081, except that rebuilding cctools has not helped.

$ echo hi > a
$ /usr/bin/lipo -info a
/usr/bin/lipo: can't figure out the architecture type of: a
$ /opt/local/bin/lipo -info a
Assertion failed: (length >=4 && "Invalid magic number length"), function IdentifyFileType, file Path.cpp, line 44.
Abort trap: 6
$ echo -n four > a
$ /opt/local/bin/lipo -info a
/opt/local/bin/lipo: can't figure out the architecture type of: a
$ port provides $(which lipo)
/opt/local/bin/lipo is provided by: cctools
$ port installed cctools
The following ports are currently installed:
  cctools @829_1+llvm31+universal (active)
$ 

Change History (10)

comment:1 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

This is slightly different than #36081, although it's tripping over the same assertion.

This has to do with the size of the file. llvm-3.1 doesn't like that it's too small. It tries to read a 4-byte magic number, but your file is only 3 bytes.

~ $ /bin/echo -n "1234" > b

~ $ /opt/local/bin/lipo -info b
/opt/local/bin/lipo: can't figure out the architecture type of: b

~ $ /bin/echo -n "123" > b

~ $ /opt/local/bin/lipo -info b
Assertion failed: (length >=4 && "Invalid magic number length"), function IdentifyFileType, file Path.cpp, line 44.
Abort trap: 6

comment:2 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff8a004212 __pthread_kill + 10
1   libsystem_c.dylib             	0x00007fff888a8af4 pthread_kill + 90
2   libLLVM-3.1.dylib             	0x000000010b92baa6 abort + 22
3   libLLVM-3.1.dylib             	0x000000010b92ba81 __assert_rtn + 81
4   libLLVM-3.1.dylib             	0x000000010b91f285 llvm::sys::IdentifyFileType(char const*, unsigned int) + 725
5   libLTO.dylib                  	0x000000010af22269 LTOModule::isBitcodeFile(void const*, unsigned long) + 9
6   libLTO.dylib                  	0x000000010af251a9 lto_module_is_object_file_in_memory + 9
7   lipo                          	0x000000010aee1bb4 is_llvm_bitcode_from_memory + 702
8   lipo                          	0x000000010aedb539 main + 5501
9   libdyld.dylib                 	0x00007fff849d27e1 start + 1

comment:3 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Note that /usr/bin/lipo does not use LTO which is why it does not hit this assertion, but if you use xcrun lipo, it will use LTO and fails with the same assertion:

$ xcrun lipo -info b
Assertion failed: (length >=4 && "Invalid magic number length"), function IdentifyFileType, file Path.cpp, line 44.
Abort trap: 6

comment:4 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Oh wait, that was actually resulting in /opt/local/bin/lipo being run.

FWIW, replacing llvm-3.1's libLTO with XCode's "fixes" the issue, so we should just fix this in llvm.

I'm seeing this with llvm-2.9 through llvm-3.2's libLTO.

comment:5 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Ok, it passes with the host's libLTO because the host has assertions disabled ...

comment:6 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

<rdar://problem/12448054>

comment:7 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

If you rebuild llvm-3.1 without the +assertions variant, I expect the issue should go away for you.

comment:8 Changed 12 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Port: llvm-3.1 added; cctools removed
Status: newassigned

comment:9 Changed 11 years ago by mfeiri

Cc: mfeiri@… removed

comment:10 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.