erikdoe / ocmock

Mock objects for Objective-C
http://ocmock.org
Apache License 2.0
2.16k stars 607 forks source link

OCMock partial mocks crash when used with objc_direct methods that directly access instance variables. #541

Open goddess-eris opened 4 months ago

goddess-eris commented 4 months ago

OCMock partial mocks crash when used with objc_direct methods that directly access instance variables. The code provided is a test case which shows the problem.

It's likely that nothing can be done about this, but it's worth adding a note to the documentation, in the section about Partial Mocks. In my opinion, this falls into the category of "There are some subtleties when using partial mocks."

MockingJayTests.m.zip

erikdoe commented 1 month ago

Thank you for providing the test. With Xcode 16 I can't reproduce the crash, though. The behaviour I'm seeing is a failing test because the assertion fails:

0x600003c009c0 foo _info 0x0 -info 0x103441510
[OCMockObjectRuntimeTests testExample] : ((_info == [self info]) is true) failed

It looks like _info is nil. That's a problem in its own right but it's different from what you are seeing. Can you confirm that you see a crash in Xcode 16? And if so, are you on Intel or Apple Silicon?