sold: XCTAssertThrows fails when linked with SOLD

This started happening after your recent fix for #17 We have an ImageLoadingDependency provider like this:

@implementation UberImageLoadingDependencyProvider

- (void)setImageLoader:(id<UBImageLoading>)imageLoader
{
    NSParameterAssert(imageLoader != nil);
    NSAssert(_imageLoader == nil, @"it should only be set once!!!!!");

    _imageLoader = imageLoader;
}

and test:

- (void)testAssertWhenSetTwice
{
    UberImageLoadingDependencyProvider *theProvider = [[UberImageLoadingDependencyProvider alloc] init];

    NSObject *imageLoader = [[NSObject alloc] init];
    XCTAssertNoThrow([theProvider setImageLoader:(id)imageLoader]);
    XCTAssertThrows([theProvider setImageLoader:(id)imageLoader]);
}

We get a crash while unwinding:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	    0x7ff834be600e __pthread_kill + 10
1   libsystem_pthread.dylib       	    0x7ff834c3d1ff pthread_kill + 263
2   libsystem_c.dylib             	    0x7ff800132fe0 abort + 130
3   libc++abi.dylib               	    0x7ff800259f72 __cxxabiv1::readEncodedPointer(unsigned char const**, unsigned char, unsigned long) + 269
4   libc++abi.dylib               	    0x7ff800259675 __gxx_personality_v0 + 389
5   libunwind.dylib               	    0x7ff8252fdcbd _Unwind_RaiseException + 233
6   libc++abi.dylib               	    0x7ff80025917d __cxa_throw + 108
7   libobjc.A.dylib               	    0x7ff80004dca6 objc_exception_throw + 307
8   Foundation                    	    0x7ff800b8637c -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 281
9   Tests   	                            0x12a262385 -[UberImageLoadingDependencyProvider setImageLoader:] + 357
10  Tests   	                            0x12a25e323 -[UberImageLoadingDependencyProviderTests testAssertWhenSetTwice] + 131

Reproducer: https://github.com/tapthaker/mold-repro-invalid-parameter

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

It was caused by a subtle error in a __compact_unwind section. Please rebuild sold and try again.