railwaycat / homebrew-emacsmacport

Emacs mac port formulae for the Homebrew package manager
BSD 2-Clause "Simplified" License
1.68k stars 126 forks source link

27.1-mac-8.1 temacs code signing causing new compile failure on M1, Big Sur 11.2.1 #237

Closed cacology closed 3 years ago

cacology commented 3 years ago

Emacs had compiled on 11.2, but something seems to have broken with 11.2.1 which gives this errors below, the key seems to be something with how the code is signed.

Below reason for termination: Namespace CODESIGNING, Code 0x2

==> make
Last 15 lines from /Users/grumpy/Library/Logs/Homebrew/emacs-mac/03.make:
  CC       json.o
  CC       macappkit.o
  CC       macfont.o
  CC       terminfo.o
  CC       lastfile.o
  CCLD     temacs
codesign -s - -f temacs.tmp
temacs.tmp: replacing existing signature
../build-aux/install-sh -c -d ../etc
/Library/Developer/CommandLineTools/usr/bin/make -C ../lisp update-subdirs
cp -f temacs bootstrap-emacs
rm -f bootstrap-emacs.pdmp
./temacs --batch  -l loadup --temacs=pbootstrap
make[1]: *** [bootstrap-emacs.pdmp] Killed: 9
make: *** [src] Error 2

Console has these seemingly related error messages:

default 17:46:00.993673-0500    amfid   /private/tmp/emacs-mac-20210212-18427-1o87dgi/mituharu-emacs-mac-2345e4ca09f2/src/temacs signature not valid: -67050
default 17:46:01.117820-0500    syspolicyd  GK evaluateScanResult: 2, PST: (vuid: 83D968B6-F403-45C3-B018-BF0AE2145963), (objid: 8330870), (team: (null)), (id: temacs-55554944a567800f670f3757b686dea6d2979f5c), (bundle_id: NOT_A_BUNDLE), 0, 0, 1, 0, 0, 0
default 17:46:01.153011-0500    kernel  CODE SIGNING: cs_invalid_page(0x102c20000): p=27045[temacs] final status 0x23000200, denying page sending SIGKILL
default 17:46:01.153021-0500    kernel  CODE SIGNING: process 27045[temacs]: rejecting invalid page at address 0x102c20000 from offset 0x0 in file "/opt/homebrew/Cellar/libtasn1/4.16.0_1/lib/libtasn1.6.dylib" (cs_mtime:1613060368.880623357 == mtime:1613060368.880623357) (signed:1 validated:1 tainted:1 nx:0 wpmapped:0 dirty:0 depth:0)
default 17:46:01.193450-0500    ReportCrash Parsing corpse data for process temacs [pid 27045]
default 17:46:02.948136-0500    ReportCrash Saved crash report for temacs[27045] version 0 to temacs_2021-02-12-174602_grumpy-air.crash

Crash Report is:

Process:               emacs-27.1 [16863]
Path:                  /opt/homebrew/*/emacs-27.1
Identifier:            emacs-27.1
Version:               0
Code Type:             ARM-64 (Native)
Parent Process:        zsh [15829]
Responsible:           Terminal [587]
User ID:               503

Date/Time:             2021-02-12 10:47:47.620 -0500
OS Version:            macOS 11.2.1 (20D74)
Report Version:        12
Anonymous UUID:        BED43C77-2D71-2885-D464-99EF89A9E607

Sleep/Wake UUID:       866172BA-48DA-4E0D-8B98-561C9ECBD155

Time Awake Since Boot: 71000 seconds
Time Since Wake:       31000 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_BAD_ACCESS (Code Signature Invalid)
Exception Codes:       0x0000000000000032, 0x0000000104ddc000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace CODESIGNING, Code 0x2

kernel messages:

VM Regions Near 0x104ddc000:
    __LINKEDIT                  104d68000-104ddc000    [  464K] r--/r-- SM=COW  /opt/homebrew/*/*.1
--> mapped file                 104ddc000-104de0000    [   16K] r--/r-x SM=PRV  Object_id=c7e4c1c3
    __TEXT                      104df0000-104f18000    [ 1184K] r-x/rwx SM=COW  /opt/homebrew/*/*.dylib

Application Specific Information:
dyld: launch, loading dependent libraries
/opt/homebrew/opt/libtasn1/lib/libtasn1.6.dylib

Thread 0 Crashed:
0   dyld                            0x0000000105158780 bcmp + 16
1   dyld                            0x0000000105119408 ImageLoaderMachO::validateFirstPages(linkedit_data_command const*, int, unsigned char const*, unsigned long, long long, ImageLoader::LinkContext const&) + 136
2   dyld                            0x00000001051203b8 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&) + 268
3   dyld                            0x0000000105117ffc ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) + 172
4   dyld                            0x0000000105100290 dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) + 668
5   dyld                            0x0000000105108dd8 dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 1328
6   dyld                            0x0000000105108824 dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 208
7   dyld                            0x0000000105108530 dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 1100
8   dyld                            0x0000000105107cf0 dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 212
9   dyld                            0x00000001050ffe0c dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, unsigned int&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 468
10  dyld                            0x00000001050ff9b0 dyld::load(char const*, dyld::LoadContext const&, unsigned int&) + 196
11  dyld                            0x000000010510977c dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*, unsigned int&) + 56
12  dyld                            0x00000001051139d4 ImageLoader::recursiveLoadLibraries(ImageLoader::LinkContext const&, bool, ImageLoader::RPathChain const&, char const*) + 344
13  dyld                            0x0000000105113d00 ImageLoader::recursiveLoadLibraries(ImageLoader::LinkContext const&, bool, ImageLoader::RPathChain const&, char const*) + 1156
14  dyld                            0x00000001051121ac ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&, char const*) + 160
15  dyld                            0x00000001051025f4 dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&, unsigned int) + 328
16  dyld                            0x0000000105104928 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 6764
17  dyld                            0x00000001050fd258 dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 476
18  dyld                            0x00000001050fd038 _dyld_start + 56

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000104ddc000   x1: 0x000000016b5b95d0   x2: 0x0000000000000680   x3: 0x0000000000040001
    x4: 0x0000000000000003   x5: 0x0000000000000000   x6: 0x0000000105180280   x7: 0x0000000000000000
    x8: 0x0000000000000000   x9: 0x000000016b5b9bc8  x10: 0x0000000000000001  x11: 0x0001803000000000
   x12: 0x0000000000000032  x13: 0x0004000000000000  x14: 0x0000000000015b28  x15: 0x000000016b5b9b48
   x16: 0x00000000000000c5  x17: 0x0000000000000000  x18: 0x0000000000000000  x19: 0x0000000105188b00
   x20: 0x0000000000000690  x21: 0x000000016b5b95d0  x22: 0x0000000104ddc000  x23: 0x0000000000000003
   x24: 0x000000016b5b9c50  x25: 0x000000016b5c16e8  x26: 0x0000000104df0968  x27: 0x000000016b5b95d0
   x28: 0x0000000000000001   fp: 0x000000016b5b8fd0   lr: 0x0000000105119408
    sp: 0x000000016b5b8f90   pc: 0x0000000105158780 cpsr: 0x20000000
   far: 0x0000000104ddc000  esr: 0x92000007

Binary Images:
       0x10483c000 -        0x1049a3fff +emacs-27.1 (0) <B9657B3C-A02D-3F98-8280-11D215498D8F> /opt/homebrew/*/emacs-27.1
       0x104df0000 -        0x104f17fff +libgnutls.30.dylib (0) <74A67886-3907-3E35-B0A3-8A5798F97283> /opt/homebrew/*/libgnutls.30.dylib
       0x104f70000 -        0x104f7bfff +libjansson.4.dylib (0) <5884EA31-2C68-3B68-9C54-CE361D76317A> /opt/homebrew/*/libjansson.4.dylib
       0x104fa4000 -        0x104ffbfff +libgmp.10.dylib (0) <A5E911FA-5131-36E7-A930-CD029FCF570F> /opt/homebrew/*/libgmp.10.dylib
       0x105018000 -        0x105037fff +libidn2.0.dylib (0) <9FD4C247-610B-37DC-8DF8-AFD6F0D3B821> /opt/homebrew/*/libidn2.0.dylib
       0x1050fc000 -        0x105177fff  dyld (832.7.3) <4AB185B3-DC20-3C03-A193-67C0E6C589D7> /usr/lib/dyld
       0x105200000 -        0x1052bffff +libp11-kit.0.dylib (0) <B56B4F03-9AA8-3C8E-BF2F-025589252CAF> /opt/homebrew/*/libp11-kit.0.dylib
       0x105318000 -        0x105477fff +libunistring.2.dylib (0) <1667CF35-8CC0-3BA9-AC57-047219BFF99B> /opt/homebrew/*/libunistring.2.dylib
       0x18ac06000 -        0x18ac07fff  libsystem_blocks.dylib (78) <9B6D4883-03E9-3785-851E-EA79FA64ADC1> /usr/lib/system/libsystem_blocks.dylib
       0x18ac08000 -        0x18ac3ffff  libxpc.dylib (2038.80.3) <BD0DFD42-0DC3-3F3D-9C04-5A2B3D93794D> /usr/lib/system/libxpc.dylib
       0x18ac40000 -        0x18ac57fff  libsystem_trace.dylib (1277.80.2) <4A466196-D2DD-367B-80AB-988F281EC3B8> /usr/lib/system/libsystem_trace.dylib
       0x18ac58000 -        0x18acccfff  libcorecrypto.dylib (1000.80.5) <9BD8FED7-2A36-3602-A5A7-0CA87C03FB84> /usr/lib/system/libcorecrypto.dylib
       0x18accd000 -        0x18acf8fff  libsystem_malloc.dylib (317.40.8) <21120432-52C1-34E4-BF01-623722FA3A41> /usr/lib/system/libsystem_malloc.dylib
       0x18acf9000 -        0x18ad3cfff  libdispatch.dylib (1271.40.12) <F5BFBD55-EF70-3659-854D-9061325EB26D> /usr/lib/system/libdispatch.dylib
       0x18ad3d000 -        0x18ad75fff  libobjc.A.dylib (818.2) <B03625B0-501E-3AC1-8E16-08B621120EAD> /usr/lib/libobjc.A.dylib
       0x18ad76000 -        0x18ad78fff  libsystem_featureflags.dylib (28.60.1) <297CC4DD-AFA4-3BA3-B4E1-0DF47E49C21E> /usr/lib/system/libsystem_featureflags.dylib
       0x18ad79000 -        0x18adf9fff  libsystem_c.dylib (1439.40.11) <A7147E08-E7C0-3842-916E-F2270A689F47> /usr/lib/system/libsystem_c.dylib
       0x18adfa000 -        0x18ae55fff  libc++.1.dylib (904.4) <B139607F-1E80-3A8E-870D-0AC022069EA1> /usr/lib/libc++.1.dylib
       0x18ae56000 -        0x18ae6ffff  libc++abi.dylib (904.4) <1DD3A1C9-D765-34FB-B8C1-87BF52CE49C0> /usr/lib/libc++abi.dylib
       0x18ae70000 -        0x18aea2fff  libsystem_kernel.dylib (7195.81.3) <55FCA547-4877-3075-8A08-FE1620BFC682> /usr/lib/system/libsystem_kernel.dylib
       0x18aea3000 -        0x18aeaefff  libsystem_pthread.dylib (454.80.2) <8E907E6C-C227-312E-944C-767093692AFF> /usr/lib/system/libsystem_pthread.dylib
       0x18aeaf000 -        0x18aeedfff  libdyld.dylib (832.7.3) <EF759BF3-97FA-30EA-A1CA-EDECFEA726FE> /usr/lib/system/libdyld.dylib
       0x18aeee000 -        0x18aef4fff  libsystem_platform.dylib (254.80.2) <8633A39C-10A2-3B44-93F7-617AB09FF640> /usr/lib/system/libsystem_platform.dylib
       0x18aef5000 -        0x18af20fff  libsystem_info.dylib (542.40.3) <4CC96CFC-7198-3F26-8C8C-20FB010CDF98> /usr/lib/system/libsystem_info.dylib
       0x18af21000 -        0x18b3cafff  com.apple.CoreFoundation (6.9 - 1774.101) <EA76C90A-23ED-3791-8FBC-8292916F0B16> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x18ccd4000 -        0x18d032fff  com.apple.security (7.0 - 59754.80.3) <C76855AD-6EE4-3413-9E6E-CC450BDB20E2> /System/Library/Frameworks/Security.framework/Versions/A/Security
       0x18d033000 -        0x18d2a4fff  libicucore.A.dylib (66109) <3CE58F97-7FC3-37D8-BB99-D6BECFC86DD2> /usr/lib/libicucore.A.dylib
       0x18d2a5000 -        0x18d2affff  libsystem_darwin.dylib (1439.40.11) <B790A863-2D74-300E-9698-A25B5602B32F> /usr/lib/system/libsystem_darwin.dylib
       0x18d6e2000 -        0x18d6edfff  libsystem_notify.dylib (279.40.4) <A7B6BDA8-5371-352E-8A36-95D46C4B07F1> /usr/lib/system/libsystem_notify.dylib
       0x18f69d000 -        0x18f6acfff  libsystem_networkextension.dylib (1295.80.3) <B6BD1267-BE59-3E42-B2B5-2BF13F17D02D> /usr/lib/system/libsystem_networkextension.dylib
       0x18f704000 -        0x18f71bfff  libsystem_asl.dylib (385) <31E28E59-1CDD-3B83-8BF0-56C675227FA2> /usr/lib/system/libsystem_asl.dylib
       0x190c8c000 -        0x190c93fff  libsystem_symptoms.dylib (1431.40.36) <0657E539-C0CE-30F8-B630-FBAE36109542> /usr/lib/system/libsystem_symptoms.dylib
       0x1917c5000 -        0x1918b0fff  libxml2.2.dylib (34.9) <E170FFEE-EB9F-3252-9B16-4A47FBAC425A> /usr/lib/libxml2.2.dylib
       0x192701000 -        0x192712fff  libsystem_containermanager.dylib (318.80.2) <0B742EA4-AFA2-36B6-AB4B-2F8ACA7211AA> /usr/lib/system/libsystem_containermanager.dylib
       0x193384000 -        0x193388fff  libsystem_configuration.dylib (1109.60.2) <AEC5E654-A5B8-343E-80B7-27D5D0D856D9> /usr/lib/system/libsystem_configuration.dylib
       0x193389000 -        0x19338dfff  libsystem_sandbox.dylib (1441.60.4) <D7CDDE27-978E-3511-AE6F-296D901290B2> /usr/lib/system/libsystem_sandbox.dylib
       0x193d49000 -        0x193d4bfff  libquarantine.dylib (119.40.2) <66942A5C-57B3-3524-BA49-0F2DA4A584D1> /usr/lib/system/libquarantine.dylib
       0x194281000 -        0x194285fff  libsystem_coreservices.dylib (127) <A9BDB37A-3E00-3FD0-AE92-7ED6FB63DD3B> /usr/lib/system/libsystem_coreservices.dylib
       0x194474000 -        0x194485fff  libz.1.dylib (76) <9005FC69-0FEF-375F-AB09-DF5CEBAD5D14> /usr/lib/libz.1.dylib
       0x194486000 -        0x1944b3fff  libsystem_m.dylib (3186.40.2) <8FADC1D2-0B61-34C7-9F1C-19D85CB07E16> /usr/lib/system/libsystem_m.dylib
       0x1944b5000 -        0x1944bafff  libmacho.dylib (973.4) <8146EF75-0B83-3A8D-A1DA-1D49AD62DE88> /usr/lib/system/libmacho.dylib
       0x1944d7000 -        0x1944e4fff  libcommonCrypto.dylib (60178.40.2) <49528AE3-1376-376C-BE61-31393A50850D> /usr/lib/system/libcommonCrypto.dylib
       0x1944e5000 -        0x1944effff  libunwind.dylib (200.10) <017E8A02-B5EA-36DB-BB73-9EDD72F1229A> /usr/lib/system/libunwind.dylib
       0x1944f0000 -        0x1944f7fff  liboah.dylib (203.30) <46D9195A-40F2-3CD5-AE73-2F6EF52ECCEC> /usr/lib/liboah.dylib
       0x1944f8000 -        0x194500fff  libcopyfile.dylib (173.40.2) <B123D3D2-7B17-3A85-AFC6-37D7AD1C5E78> /usr/lib/system/libcopyfile.dylib
       0x194501000 -        0x194504fff  libcompiler_rt.dylib (102.2) <EDB437BA-9775-3761-A646-58086BD12C4D> /usr/lib/system/libcompiler_rt.dylib
       0x194505000 -        0x194507fff  libsystem_collections.dylib (1439.40.11) <B252D66F-979E-3ABA-83AC-0BDED154A9A7> /usr/lib/system/libsystem_collections.dylib
       0x194508000 -        0x19450afff  libsystem_secinit.dylib (87.60.1) <F250D007-BE32-3C94-86DD-33598CF6D3E3> /usr/lib/system/libsystem_secinit.dylib
       0x19450b000 -        0x19450dfff  libremovefile.dylib (49.40.3) <FE46F050-5062-3117-88B2-E727C8AFABA6> /usr/lib/system/libremovefile.dylib
       0x19450e000 -        0x19450efff  libkeymgr.dylib (31) <1EE40BB9-C661-3FB2-8409-44E93D2820DA> /usr/lib/system/libkeymgr.dylib
       0x19450f000 -        0x194517fff  libsystem_dnssd.dylib (1310.80.1) <7F309D4C-1FE5-3C27-8403-9F305D7D8725> /usr/lib/system/libsystem_dnssd.dylib
       0x194518000 -        0x19451dfff  libcache.dylib (83) <C8504CA2-F42B-312F-B79D-2B1C7E64FA4D> /usr/lib/system/libcache.dylib
       0x19451e000 -        0x19451ffff  libSystem.B.dylib (1292.60.1) <CF348B98-3432-3B5A-920B-2C7AFE89000D> /usr/lib/libSystem.B.dylib
       0x197932000 -        0x197932fff  liblaunch.dylib (2038.80.3) <327A64BF-8C2C-303D-91E4-70A168C5D87F> /usr/lib/system/liblaunch.dylib
       0x199dfc000 -        0x199dfcfff  libsystem_product_info_filter.dylib (8.40.1) <616C96CE-226D-3719-B37F-A3FCAA32591A> /usr/lib/system/libsystem_product_info_filter.dylib
       0x1aad90000 -        0x1aadc0fff  libncurses.5.4.dylib (57) <30E9C91D-5587-33CF-B16B-B8DAD63CC204> /usr/lib/libncurses.5.4.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: 63098
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=502.2M resident=0K(0%) swapped_out_or_unallocated=502.2M(100%)
Writable regions: Total=8880K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=8880K(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
STACK GUARD                       56.0M        1 
Stack                             8176K        1 
__AUTH                              55K       15 
__AUTH_CONST                      1227K       44 
__DATA                            4346K       49 
__DATA_CONST                      2649K       50 
__DATA_DIRTY                       103K       25 
__LINKEDIT                       480.9M       10 
__OBJC_CONST                        43K        7 
__OBJC_RO                         64.5M        1 
__OBJC_RW                         2544K        1 
__TEXT                            21.4M       56 
__UNICODE                          588K        1 
mapped file                         16K        1 
===========                     =======  ======= 
TOTAL                            642.1M      262 

brew config

HOMEBREW_VERSION: 3.0.1
ORIGIN: https://github.com/Homebrew/brew
HEAD: c951be8d3c7b339c7e759b7c40aec859e09a70a5
Last commit: 2 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: de89b9fcdb50af78b1ca93e1f317507fbb3c405f
Core tap last commit: 35 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 12.0 build 1200
Git: 2.24.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.2.1-arm64
CLT: 12.4.0.0.1.1610135815
Xcode: 12.4
XQuartz: 2.7.11 => /opt/X11
Rosetta 2: false
cacology commented 3 years ago

Solved:

Something was borked in my stack, so I reinstalled XCode and CLT from developer.apple.com (not the app store), dumped a Brewfile, uninstalled ARM Homebrew, reinstalled, and ran the Brewfile. Compilation then went without a hitch. I bet I didn't need to reinstall XCode, but I'm still recording this here in case my solution helps someone else.

The key insight came from this discussion:

https://github.com/d12frosted/homebrew-emacs-plus/issues/292#issuecomment-778648261