You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing instances of non-trivial C++ objects as Objective-C++ method parameters causes unexpected behavior, even if appropriate copy constructors and assignment operators have been provided, e.g. in case of smart pointer implementations - crashes.
CppParam.h (MSCVP)
#pragma once
classCppParam
{
public:CppParam();
};
Exception thrown at 0x0FB17FEC (LIBOBJC2.DLL) in PartyCrasher.exe: 0xC0000005: Access violation reading location 0x00000000.
Notes:
1.) The problem does not occur under Apple Xcode/iOS.
2.) The problem does not occur for single-parameter Objective-C++ method calls (Clang requires, thus uses, a copy constructor), hence it is probably not a problem with yasper::ptr<> itself, the sample smart pointer implementation. Some kind of Objective-C++ variadic memcpy() -ing stuff around instead of using a copy constructor?
As of: WinObjC version 0.2.160927 (September 27, 2016).
The text was updated successfully, but these errors were encountered:
In doMe2 and doMe3, the function begins with the ARC prologue that should take a strong reference on the NSObject* parameter.
That usually looks something like this:
00B579A0 push dword ptr [ebp+10h] ; parameter area is above ebp00B579A3 leaeax,[param]00B579A6 pusheax00B579A7 call _objc_storeStrong (0B646B6h)
which corresponds to the call objc_storeStrong(¶m_local_temp, param_passed_in_as_argument).
However, what's getting emitted in 2 and 3 above looks more like this:
00B578D0 push dword ptr [ebp-10h] ; local temp area is below ebp00B578D3 push dword ptr [ebp-10h]00B578D6 call _objc_storeStrong (0B646B6h)
This corresponds to objc_storeStrong(¶m_local_temp, ¶m_local_temp).
It looks like marking the NSObject parameter __unsafe_unretained fixes the issue (at, of course, a cost), as further references to the parameter don't codegen improperly.
Passing instances of non-trivial C++ objects as Objective-C++ method parameters causes unexpected behavior, even if appropriate copy constructors and assignment operators have been provided, e.g. in case of smart pointer implementations - crashes.
CppParam.h (MSCVP)
CppParam.cpp (MSCVP)
partyCrasher.mm (Clang)
The relevant error message:
Notes:
1.) The problem does not occur under Apple Xcode/iOS.
2.) The problem does not occur for single-parameter Objective-C++ method calls (Clang requires, thus uses, a copy constructor), hence it is probably not a problem with
yasper::ptr<>
itself, the sample smart pointer implementation. Some kind of Objective-C++ variadicmemcpy()
-ing stuff around instead of using a copy constructor?As of: WinObjC version 0.2.160927 (September 27, 2016).
The text was updated successfully, but these errors were encountered: