2 Replies
      Latest reply on May 26, 2020 3:52 PM by matthew208
      sushantgautam Level 1 Level 1 (0 points)

        Hi All,

        I have been working on an application developed with Electron. The application is working fine after code signing and notarization (code signing has been done with the use of electron-builder, notarization has been done by using electron-notarize). There is only one specific point where my application breaks and throws an error message.
        I am using arduino as 3rd party inside my app. When I try to compile the code for esp32 using arduino-builder, the app tries to run following command via child_process and throws error



        python "/Applications/ElectronArduino.app/Contents/Resources/arduino-1.8.5/hardware/espressif/esp32/tools/gen_esp32part.py" -q "/Applications/ElectronArduino.app/Contents/Resources/arduino-1.8.5/hardware/espressif/esp32/tools/partitions/default.csv" "/var/folders/79/4j1c9rw94cj3zv_k12zhq6jm0000gn/T/sdk/ar.ino.partitions.bin"


        "/Applications/ElectronArduino.app/Contents/Resources/arduino-1.8.5/hardware/espressif/esp32/tools/esptool/esptool" --chip esp32 elf2image --flash_mode "dio" --flash_freq "80m" --flash_size "16MB" -o "/var/folders/79/4j1c9rw94cj3zv_k12zhq6jm0000gn/T/sdk/ar.ino.bin" "/var/folders/79/4j1c9rw94cj3zv_k12zhq6jm0000gn/T/sdk/ar.ino.elf"


        signal: killed





        esptool quit ununexpectedly



        Process:               esptool [7049]
        Path:                  /Applications/ElectronArduino.app/Contents/Resources/arduino-1.8.5/hardware/espressif/esp32/tools/esptool/esptool
        Identifier:            esptool
        Version:               ???
        Code Type:             X86-64 (Native)
        Parent Process:        ??? [7048]
        Responsible:           esptool [7049]
        User ID:               501
        Date/Time:             2019-10-11 13:23:36.755 +0530
        OS Version:            Mac OS X 10.14.6 (18G95)
        Report Version:        12
        Anonymous UUID:        2704150D-798D-484E-E2CC-F5C747AE11E8
        Sleep/Wake UUID:       7068B47E-8772-4031-83EE-8DFB03CA5C23
        Time Awake Since Boot: 47000 seconds
        Time Since Wake:       53000 seconds
        System Integrity Protection: enabled
        Crashed Thread:        0  Dispatch queue: com.apple.main-thread
        Exception Type:        EXC_BAD_ACCESS (Code Signature Invalid)
        Exception Codes:       0x0000000000000032, 0x0000000107025000
        Exception Note:        EXC_CORPSE_NOTIFY
        Termination Reason:    Namespace CODESIGNING, Code 0x2
        kernel messages:
        VM Regions Near 0x107025000:
            MALLOC metadata        0000000107024000-0000000107025000 [    4K] r--/rwx SM=PRV
        --> mapped file            0000000107025000-0000000107026000 [    4K] r--/r-x SM=PRV  Object_id=a6fd3e69
            __TEXT                 0000000108e4a000-0000000108eb5000 [  428K] r-x/rwx SM=COW  /usr/lib/dyld
        Application Specific Information:
        dyld: in dlopen()
        Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
        0   dyld                          0x0000000108e8b3b0 memcmp + 208
        1   dyld                          0x0000000108e60a30 ImageLoaderMachO::validateFirstPages(linkedit_data_command const*, int, unsigned char const*, unsigned long, long long, ImageLoader::LinkContext const&) + 104
        2   dyld                          0x0000000108e66756 ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, encryption_info_command const*, ImageLoader::LinkContext const&) + 278
        3   dyld                          0x0000000108e5fa90 ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) + 158
        4   dyld                          0x0000000108e4df39 dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) + 769
        5   dyld                          0x0000000108e54cc6 dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector >*) + 1053
        6   dyld                          0x0000000108e54847 dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector >*) + 185
        7   dyld                          0x0000000108e545a1 dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector >*) + 1387
        8   dyld                          0x0000000108e53d18 dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector >*) + 135
        9   dyld                          0x0000000108e4daca dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector >*) + 496
        10  dyld                          0x0000000108e4d659 dyld::load(char const*, dyld::LoadContext const&, unsigned int&) + 185
        11  dyld                          0x0000000108e5931f dlopen_internal + 418
        12  libdyld.dylib                  0x00007fff7ccfdd43 dlopen + 200
        13  esptool                        0x0000000106c49bf7 0x106c47000 + 11255
        14  esptool                        0x0000000106c48ad3 0x106c47000 + 6867
        15  esptool                        0x0000000106c48df9 0x106c47000 + 7673
        16  esptool                        0x0000000106c478a4 0x106c47000 + 2212
        Thread 0 crashed with X86 Thread State (64-bit):
          rax: 0x0000000000000000  rbx: 0x0000000107025000  rcx: 0x0000000000000000  rdx: 0x0000000000000730
          rdi: 0x0000000107025000  rsi: 0x00007ffee8fae700  rbp: 0x00007ffee8fae0e0  rsp: 0x00007ffee8fae0e0
           r8: 0x0000000000000006   r9: 0x0000000000001000  r10: 0x0000000000000001  r11: 0x0000000000000202
          r12: 0x0000000000001000  r13: 0x0000000000000006  r14: 0x0000000000000730  r15: 0x00007f989e402670
          rip: 0x0000000108e8b3b0  rfl: 0x0000000000010246  cr2: 0x0000000107025000
        Logical CPU:     0
        Error Code:      0x00000004
        Trap Number:     14
        Binary Images:
               0x106c47000 -        0x106c4cff7 +esptool (???) <55B994E1-1614-3E85-B704-22C6158BB3D8> /Applications/ElectronArduino.app/Contents/Resources/arduino-1.8.5/hardware/espressif/esp32/tools/esptool/esptool
               0x108e4a000 -        0x108eb470f  dyld (655.1.1)  /usr/lib/dyld
            0x7fff79cf9000 -     0x7fff79cfaffb  libSystem.B.dylib (1252.250.1)  /usr/lib/libSystem.B.dylib
            0x7fff79f3c000 -     0x7fff79f8fff7  libc++.1.dylib (400.9.4) <9A60A190-6C34-339F-BB3D-AACE942009A4> /usr/lib/libc++.1.dylib
            0x7fff79f90000 -     0x7fff79fa5ff7  libc++abi.dylib (400.17) <38C09CED-9090-3719-90F3-04A2749F5428> /usr/lib/libc++abi.dylib
            0x7fff7b530000 -     0x7fff7bcb5fdf  libobjc.A.dylib (756.2) <7C312627-43CB-3234-9324-4DEA92D59F50> /usr/lib/libobjc.A.dylib
            0x7fff7c39f000 -     0x7fff7c3b1ff7  libz.1.dylib (70.200.4)  /usr/lib/libz.1.dylib
            0x7fff7cb95000 -     0x7fff7cb99ff3  libcache.dylib (81) <1987D1E1-DB11-3291-B12A-EBD55848E02D> /usr/lib/system/libcache.dylib
            0x7fff7cb9a000 -     0x7fff7cba4ff3  libcommonCrypto.dylib (60118.250.2) <1765BB6E-6784-3653-B16B-CB839721DC9A> /usr/lib/system/libcommonCrypto.dylib
            0x7fff7cba5000 -     0x7fff7cbacff7  libcompiler_rt.dylib (63.4) <5212BA7B-B7EA-37B4-AF6E-AC4F507EDFB8> /usr/lib/system/libcompiler_rt.dylib
            0x7fff7cbad000 -     0x7fff7cbb6ff7  libcopyfile.dylib (146.250.1) <98CD00CD-9B91-3B5C-A9DB-842638050FA8> /usr/lib/system/libcopyfile.dylib
            0x7fff7cbb7000 -     0x7fff7cc3bfc3  libcorecrypto.dylib (602.260.2) <01464D24-570C-3B83-9D18-467769E0FCDD> /usr/lib/system/libcorecrypto.dylib
            0x7fff7ccc2000 -     0x7fff7ccfbff7  libdispatch.dylib (1008.270.1) <97273678-E94C-3C8C-89F6-2E2020F4B43B> /usr/lib/system/libdispatch.dylib
            0x7fff7ccfc000 -     0x7fff7cd28ff7  libdyld.dylib (655.1.1) <002418CC-AD11-3D10-865B-015591D24E6C> /usr/lib/system/libdyld.dylib
            0x7fff7cd29000 -     0x7fff7cd29ffb  libkeymgr.dylib (30) <0D0F9CA2-8D5A-3273-8723-59987B5827F2> /usr/lib/system/libkeymgr.dylib
            0x7fff7cd37000 -     0x7fff7cd37ff7  liblaunch.dylib (1336.261.2) <2B07E27E-D404-3E98-9D28-BCA641E5C479> /usr/lib/system/liblaunch.dylib
            0x7fff7cd38000 -     0x7fff7cd3dfff  libmacho.dylib (927.0.3)  /usr/lib/system/libmacho.dylib
            0x7fff7cd3e000 -     0x7fff7cd40ffb  libquarantine.dylib (86.220.1) <6D0BC770-7348-3608-9254-F7FFBD347634> /usr/lib/system/libquarantine.dylib
            0x7fff7cd41000 -     0x7fff7cd42ff7  libremovefile.dylib (45.200.2) <9FBEB2FF-EEBE-31BC-BCFC-C71F8D0E99B6> /usr/lib/system/libremovefile.dylib
            0x7fff7cd43000 -     0x7fff7cd5aff3  libsystem_asl.dylib (356.200.4)  /usr/lib/system/libsystem_asl.dylib
            0x7fff7cd5b000 -     0x7fff7cd5bff7  libsystem_blocks.dylib (73)  /usr/lib/system/libsystem_blocks.dylib
            0x7fff7cd5c000 -     0x7fff7cde3fff  libsystem_c.dylib (1272.250.1) <7EDACF78-2FA3-35B8-B051-D70475A35117> /usr/lib/system/libsystem_c.dylib
            0x7fff7cde4000 -     0x7fff7cde7ffb  libsystem_configuration.dylib (963.270.3) <2B4A836D-68A4-33E6-8D48-CD4486B03387> /usr/lib/system/libsystem_configuration.dylib
            0x7fff7cde8000 -     0x7fff7cdebff7  libsystem_coreservices.dylib (66) <719F75A4-74C5-3BA6-A09E-0C5A3E5889D7> /usr/lib/system/libsystem_coreservices.dylib
            0x7fff7cdec000 -     0x7fff7cdf2fff  libsystem_darwin.dylib (1272.250.1)  /usr/lib/system/libsystem_darwin.dylib
            0x7fff7cdf3000 -     0x7fff7cdf9ff7  libsystem_dnssd.dylib (878.270.2)  /usr/lib/system/libsystem_dnssd.dylib
            0x7fff7cdfa000 -     0x7fff7ce45ffb  libsystem_info.dylib (517.200.9)  /usr/lib/system/libsystem_info.dylib
            0x7fff7ce46000 -     0x7fff7ce6eff7  libsystem_kernel.dylib (4903.271.2)  /usr/lib/system/libsystem_kernel.dylib
            0x7fff7ce6f000 -     0x7fff7cebaff7  libsystem_m.dylib (3158.200.7)  /usr/lib/system/libsystem_m.dylib
            0x7fff7cebb000 -     0x7fff7cee5fff  libsystem_malloc.dylib (166.270.1) <011F3AD0-8E6A-3A89-AE64-6E5F6840F30A> /usr/lib/system/libsystem_malloc.dylib
            0x7fff7cee6000 -     0x7fff7cef0ff7  libsystem_networkextension.dylib (767.250.2)  /usr/lib/system/libsystem_networkextension.dylib
            0x7fff7cef1000 -     0x7fff7cef8fff  libsystem_notify.dylib (172.200.21) <145B5CFC-CF73-33CE-BD3D-E8DDE268FFDE> /usr/lib/system/libsystem_notify.dylib
            0x7fff7cef9000 -     0x7fff7cf02fef  libsystem_platform.dylib (177.270.1) <9D1FE5E4-EB7D-3B3F-A8D1-A96D9CF1348C> /usr/lib/system/libsystem_platform.dylib
            0x7fff7cf03000 -     0x7fff7cf0dff7  libsystem_pthread.dylib (330.250.2) <2D5C08FF-484F-3D59-9132-CE1DCB3F76D7> /usr/lib/system/libsystem_pthread.dylib
            0x7fff7cf0e000 -     0x7fff7cf11ff7  libsystem_sandbox.dylib (851.270.1) <9494594B-5199-3186-82AB-5FF8BED6EE16> /usr/lib/system/libsystem_sandbox.dylib
            0x7fff7cf12000 -     0x7fff7cf14ff3  libsystem_secinit.dylib (30.260.2)  /usr/lib/system/libsystem_secinit.dylib
            0x7fff7cf15000 -     0x7fff7cf1cff3  libsystem_symptoms.dylib (820.267.1) <03F1C2DD-0F5A-3D9D-88F6-B26C0F94EB52> /usr/lib/system/libsystem_symptoms.dylib
            0x7fff7cf1d000 -     0x7fff7cf32fff  libsystem_trace.dylib (906.260.1)  /usr/lib/system/libsystem_trace.dylib
            0x7fff7cf34000 -     0x7fff7cf39ffb  libunwind.dylib (35.4) <24A97A67-F017-3CFC-B0D0-6BD0224B1336> /usr/lib/system/libunwind.dylib
            0x7fff7cf3a000 -     0x7fff7cf69fff  libxpc.dylib (1336.261.2) <7DEE2300-6D8E-3C00-9C63-E3E80D56B0C4> /usr/lib/system/libxpc.dylib
        External Modification Summary:
          Calls made by other processes targeting this process:
            task_for_pid: 0
            thread_create: 0
            thread_set_state: 0
          Calls made by this process:
            task_for_pid: 0
            thread_create: 0
            thread_set_state: 0
          Calls made by all processes on this machine:
            task_for_pid: 28842
            thread_create: 0
            thread_set_state: 0
        VM Region Summary:
        ReadOnly portion of Libraries: Total=237.8M resident=0K(0%) swapped_out_or_unallocated=237.8M(100%)
        Writable regions: Total=17.3M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=17.3M(100%)
                                        VIRTUAL   REGION
        REGION TYPE                        SIZE    COUNT (non-coalesced)
        ===========                     =======  =======
        Kernel Alloc Once                    8K        1
        MALLOC                            9260K        7
        MALLOC guard page                   16K        4
        STACK GUARD                       56.0M        1
        Stack                             8192K        1
        __DATA                            2272K       41
        __LINKEDIT                       226.1M        3
        __TEXT                            11.7M       40
        mapped file                          4K        1
        shared memory                        8K        2
        ===========                     =======  =======
        TOTAL                            313.1M      101



        My entitlement file includes :



            Access Microphone
            Access camera



        I am stuck with this issue for so long. Please help.
        Let me know for any additional details, if required.

        • Re: EXC_CORPSE_NOTIFY, App terminated, Application specific information: dyld: in dlopen() .....Python
          eskimo Apple Staff Apple Staff (13,905 points)

          There are lots of moving parts here, so it’s hard to be sure what’s going on.  Note this:

          12  libdyld.dylib … dlopen + 200  
          13  esptool       … 0x106c47000 + 11255

          It suggests that esptool has call dlopen.  And this:

          Application Specific Information:  
          dyld: in dlopen()  

          which suggests its trying to dlopen a Mach-O image from the temporary directory.  It’s likely that this image was built or signed in a way that’s incompatible with the hardened runtime, but it’s hard to say more without knowing more about where it came from.  For that you’ll need to dig into the esptool code.  To start, I recommend that you find a way to symbolicate frames 13 through 16 in this backtrace:

          12  libdyld.dylib … dlopen + 200  
          13  esptool       … 0x106c47000 + 11255  
          14  esptool       … 0x106c47000 + 6867  
          15  esptool       … 0x106c47000 + 7673  
          16  esptool       … 0x106c47000 + 2212

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: EXC_CORPSE_NOTIFY, App terminated, Application specific information: dyld: in dlopen() .....Python
              matthew208 Level 1 Level 1 (0 points)

              I am pretty sure the tool that is failing is a python tool that has been compiled using pyinstaller.  I am seeing the same thing.

              After a lot of trouble here's what I did

              Onefile mac apps wont work because they unpack the bootloader junk into the temp directory and then the app is running unsigned code.  Gatekeeper sigkills the app.  You can detect what's going on by looking for your app in the console.

              You will need
              - A pyinstaller generated .app file with all the pyinstaller bootloader stuff inside the Contents/MacOS folder
              - To do this, use pyinstaller to make a --windowed application, and made sure NOT to use --onefile
                -- This will generate a folder and a .app, all you need is the .app file.

              - You will need to codesign --deep this .app file to sign all the .so files from pyInstaller
              - To be able to notarize, you will have to pass in 
                   --entitlements entitlements.plist
                   --options runtime

              codesign --sign IDENTITYHASH  --deep --force  --options runtime  --entitlements entitlements.plist PyInstallerThing.app

              - PyInstaller generates stuff in the MacOS folder with symlinks to the Resources folder. 
              This is FINE, but if you ever copy it on the command line, make sure to cp -R to preserve the symlinks, otherwise you will not be able to codesign - it will choke on the .h file from python includes.