Apache Cordova
  1. Apache Cordova
  2. CB-6150

objc_msgSend causes EXC_BAD_ACCESS with plugins on arm64

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.4.0
    • Fix Version/s: 3.5.0
    • Component/s: iOS
    • Labels:
    • Environment:

      iOS 7.0.6 arm64

      Description

      This bug was mentioned before in https://issues.apache.org/jira/browse/CB-5888

      The code in CDVCommandQueue line 197:
      objc_msgSend(obj, normalSelector, command);
      Causes a EXC_BAD_ACCESS on arm64.

      According to Apple's docs at https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html :

      An exception to the casting rule described above is when you are calling the objc_msgSend function or any other similar functions in the Objective-C runtime that send messages. Although the prototype for the message functions has a variadic form, the method function that is called by the Objective-C runtime does not share the same prototype. The Objective-C runtime directly dispatches to the function that implements the method, so the calling conventions are mismatched, as described previously. Therefore you must cast the objc_msgSend function to a prototype that matches the method function being called.

      This bug can be solved by explicit casting, like so:

      ((void(*)(id, SEL, id))objc_msgSend)(obj, normalSelector, command);
      

        Issue Links

          Activity

          Hide
          Shazron Abdullah added a comment -

          Confirmed the bug.

          Two fixes:
          1. https://github.com/apache/cordova-ios/blob/7da5f2df3417de68a1b540bc00c11a95ce3dc7d6/CordovaLib/Classes/CDVCommandQueue.m#L197

          ((void(*)(id, SEL, id))objc_msgSend)(obj, normalSelector, command);
          

          2. https://github.com/apache/cordova-ios/blob/7da5f2df3417de68a1b540bc00c11a95ce3dc7d6/CordovaLib/Classes/CDVViewController.m#L700

          if ( ((BOOL(*)(id, SEL, id, int)) objc_msgSend)(plugin, selector, request, navigationType) == YES) {
          
          Show
          Shazron Abdullah added a comment - Confirmed the bug. Two fixes: 1. https://github.com/apache/cordova-ios/blob/7da5f2df3417de68a1b540bc00c11a95ce3dc7d6/CordovaLib/Classes/CDVCommandQueue.m#L197 ((void(*)(id, SEL, id))objc_msgSend)(obj, normalSelector, command); 2. https://github.com/apache/cordova-ios/blob/7da5f2df3417de68a1b540bc00c11a95ce3dc7d6/CordovaLib/Classes/CDVViewController.m#L700 if ( ((BOOL(*)(id, SEL, id, int )) objc_msgSend)(plugin, selector, request, navigationType) == YES) {
          Hide
          ASF subversion and git services added a comment -

          Commit 82ce4f249faf11f759cfd900974e7662c4c08688 in cordova-ios's branch refs/heads/master from Shazron Abdullah
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=82ce4f2 ]

          CB-6150 - objc_msgSend causes EXC_BAD_ACCESS with plugins on arm64

          Show
          ASF subversion and git services added a comment - Commit 82ce4f249faf11f759cfd900974e7662c4c08688 in cordova-ios's branch refs/heads/master from Shazron Abdullah [ https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;h=82ce4f2 ] CB-6150 - objc_msgSend causes EXC_BAD_ACCESS with plugins on arm64

            People

            • Assignee:
              Shazron Abdullah
              Reporter:
              Joris Verbogt
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development