Open rmaloney3 opened 2 years ago
Got any crash logs you could add? Be interested to know what OS you are running on as well.
Crash report on macOS 12.4 (21F79): xctest-2022-07-20-102120.txt
I can repreduce the crash, with a different stack trace. Not sure what to do here. It feels like another optimisation in the runtime, which makes immutable arrays somehow special so that the setup and clean up doesn't work as expected for them.
One option would be to add a check for immutable arrays and consider it an error when a test tries to create a partial mock for an immutable array (which is a questionable thing to do anyway).
By the way, to my knowledge there is no NSConstantArray
. The only thing that's publicly visible is NSArray
and NSMutableArray
. At runtime you'll also see classes like __NSArrayI
.
OCMock 3.9.1 Xcode 14.0 beta 3 (14A5270f)
Using the above versions, when initializing an
OCMPartialMock
with anNSConstantArray
, it results in anEXC_BAD_ACCESS
crash in-[OCPartialMockObject prepareObjectForInstanceMethodMocking]
on line 160 ofOCPartialMockObject.m
.Here is an example that reproduces the crash:
Modifying the code to use an
NSArray
instead of anNSConstantArray
does not crash: