-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues Identified by TSan and UBSan #362
Comments
Turning on Guard Malloc also found some issues. In the - (void)testStopMockingDisposesMetaClass
{
id mock = [[OCClassMockObject alloc] initWithClass:[TestClassWithClassMethods class]];
NSString *createdSubclassName = @(object_getClassName([TestClassWithClassMethods class]));
XCTAssertNotNil(objc_lookUpClass(createdSubclassName.UTF8String));
[mock stopMocking];
XCTAssertNil(objc_lookUpClass(createdSubclassName.UTF8String));
} - (void)testSecondClassMockDisposesFirstMetaClass
{
id mock1 = [[OCClassMockObject alloc] initWithClass:[TestClassWithClassMethods class]];
NSString *createdSubclassName1 = @(object_getClassName([TestClassWithClassMethods class]));
XCTAssertNotNil(objc_lookUpClass(createdSubclassName1.UTF8String));
id mock2 = [[OCClassMockObject alloc] initWithClass:[TestClassWithClassMethods class]];
NSString *createdSubclassName2 = @(object_getClassName([TestClassWithClassMethods class]));
XCTAssertNotNil(objc_lookUpClass(createdSubclassName2.UTF8String));
[mock1 stopMocking];
[mock2 stopMocking];
XCTAssertNil(objc_lookUpClass(createdSubclassName1.UTF8String));
XCTAssertNil(objc_lookUpClass(createdSubclassName2.UTF8String));
} |
Unfortunately, I think I've hit my debugging with LLDB knowledge limit as I can't figure out what object the retain is crashing on:
I'm attaching the .xcresult file for the test run as it contains the crashes: TestResults.xcresult.zip To look at the crashes, unzip and then right-click the TestResults.xcresults file and select Show Package Contents. The crashes are in the Attachments folder. |
@carllindberg Sorry for summoning you out of the blue, but you are one of the few people that I know that might be able to help me figure this out. |
The issue identified by guard malloc was resolved in 662bbeb. The issue identified by UBSan was partially addressed by d00d8f3. Since To ignore this, the test causing this can be annotated with |
Hi Erik, I'm working on a branch of OCMock to add additional quality checks to the project (ASan, TSan, & UBSan). While working on implementing these additional checks when running the unit tests, they uncovered some issues.
TSan Issues
The thread sanitizer found 5 tests involving notification mock objects that all failed with the same error: when verify is called on the mock, you end up with a
Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
. TSan is indicating that there is a memory read error, so I'm wondering if the notification mock is either in the process of being released or is already released sinceOCObserverMockObject
has theautoRemoveFromCenter:
concept.UBSan Issue
The undefined behavior sanitizer found 1 test that exposed a nullability issue in
setupForwarderForSelector:
inOCPartialMockObject
. ThetestStubsMethodImplementation
test inOCMockForwardingTargetTests
indicates that when the forwarder is being setup, theoriginalMethod
is nil, so when you pass that tomethod_getImplementation
, that is not allowed since the method parameter is marked explicitly as nonnull. I'm wondering if you need to return early there or do something similar to a few lines below where you are checking if the type encoding is null.I'd be happy to fix these on my branch where I'm adding these checks in, but I'm unsure of the correct solution.
The text was updated successfully, but these errors were encountered: