Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Klayout quits unexpectedly after building from source code on MacBook Air M1, MacOS Ventura 13.5 #1481

Open
jasminabrar opened this issue Sep 11, 2023 · 10 comments
Labels

Comments

@jasminabrar
Copy link

I have tried building KLayout from source code on my MacBook Air M1, MacOS Ventura using the instructions under 6B-6D in the official documentation (https://github.com/lukasc-ubc/klayout/tree/master/macbuild) as well as following the command from issue #1452. Using the command from issue #1452 I have attempted several combinations of ruby and qt versions (ruby3.1, ruby3.2, qt5, qt6), as I suspected the errors presented during KLayout's crash may have been caused by building with a wrong software version. However, regardless of the build method I use, KLayout quits unexpectedly when I attempt to open the application due to an invalid code signature.

I am unsure of how to proceed and am reaching out to the community for help on how I should proceed. Some individuals I have seem in related GitHub issues are @klayoutmatthias @Kazzz-S @stefanottili @thomaslima. Any of your input would be greatly appreciated. Thank you.

Here is the content of the error report:


Translated Report (Full Report Below)

Incident Identifier: CF4BF077-5508-45F9-9BAF-A6169832EC69
CrashReporter Key: 612438D0-5FCF-B469-5D0D-17FBD3BA95A2
Hardware Model: MacBookAir10,1
Process: klayout [41358]
Path: /Applications/klayout_githubissues_ruby3.1.app/Contents/MacOS/klayout
Identifier: de.klayout
Version: 0.28.11 (0.28.11)
Code Type: ARM-64 (Native)
Role: Background
Parent Process: launchd [1]
Coalition: de.klayout [86947]

Date/Time: 2023-09-11 14:02:13.6606 -0700
Launch Time: 2023-09-11 14:02:13.1950 -0700
OS Version: macOS 13.5 (22G74)
Release Type: User
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
Exception Subtype: UNKNOWN_0x32 at 0x000000010265c000
Exception Codes: 0x0000000000000032, 0x000000010265c000
VM Region Info: 0x10265c000 is in 0x10265c000-0x10266c000; bytes after start: 0 bytes before end: 65535
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
---> __TEXT 10265c000-10266c000 [ 64K] r-x/r-x SM=COW
__DATA_CONST 10266c000-102670000 [ 16K] rw-/rw- SM=COW
Termination Reason: CODESIGNING 2 Invalid Page

Triggered by Thread: 0

Thread 0 Crashed:
0 0x102a161e4 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 52
1 0x102a181cc dyld3::MachOFile::forEachSupportedPlatform(void (dyld3::Platform, unsigned int, unsigned int) block_pointer) const + 160
2 0x102a69e0c dyld3::MachOFile::isBuiltForSimulator() const + 124
3 0x102a198e4 start + 632

Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x000000010265c000 x1: 0x000000016d7a3828 x2: 0x000000016d7a37d0 x3: 0x0000000102a15e2e
x4: 0x0000000000000075 x5: 0x0000000000000075 x6: 0x0000000000000000 x7: 0x0000000000000a40
x8: 0x000000016d7a3808 x9: 0x0000000102aa7530 x10: 0x0000000102a92000 x11: 0x0000000102a9e9b9
x12: 0x0000000000000065 x13: 0x0000000000000073 x14: 0x0000000000056250 x15: 0x0000000000000000
x16: 0x0000000102a1826c x17: 0x6ae100016d7a37d0 x18: 0x0000000000000000 x19: 0x000000016d7a3828
x20: 0x000000010265c000 x21: 0x000000016d7a37d0 x22: 0x000000016d7a3a08 x23: 0x000000016d7a39e0
x24: 0x000000016d7a3960 x25: 0x0000000000000000 x26: 0x0000000000000000 x27: 0x0000000000000000
x28: 0x0000000000000000 fp: 0x000000016d7a37c0 lr: 0x190b800102a181cc
sp: 0x000000016d7a3730 pc: 0x0000000102a161e4 cpsr: 0x80001000
far: 0x000000010265c000 esr: 0x92000007 (Data Abort) byte read Translation fault

Binary Images:
0x102a14000 - 0x102aa3fff () ???
0x10265c000 - 0x10266bfff (
) <05fef845-122a-3dfb-a85c-d8c319218603> ???

Error Formulating Crash Report:
dyld_process_snapshot_get_shared_cache failed

EOF


Full Report

{"app_name":"klayout","timestamp":"2023-09-11 14:02:13.00 -0700","app_version":"0.28.11","slice_uuid":"05fef845-122a-3dfb-a85c-d8c319218603","build_version":"0.28.11","platform":0,"bundleID":"de.klayout","share_with_app_devs":1,"is_first_party":0,"bug_type":"309","os_version":"macOS 13.5 (22G74)","roots_installed":0,"name":"klayout","incident_id":"CF4BF077-5508-45F9-9BAF-A6169832EC69"}
{
"uptime" : 350000,
"procRole" : "Background",
"version" : 2,
"userID" : 503,
"deployVersion" : 210,
"modelCode" : "MacBookAir10,1",
"coalitionID" : 86947,
"osVersion" : {
"train" : "macOS 13.5",
"build" : "22G74",
"releaseType" : "User"
},
"captureTime" : "2023-09-11 14:02:13.6606 -0700",
"incident" : "CF4BF077-5508-45F9-9BAF-A6169832EC69",
"pid" : 41358,
"translated" : false,
"cpuType" : "ARM-64",
"roots_installed" : 0,
"bug_type" : "309",
"procLaunch" : "2023-09-11 14:02:13.1950 -0700",
"procStartAbsTime" : 8605198367459,
"procExitAbsTime" : 8605208623474,
"procName" : "klayout",
"procPath" : "/Applications/klayout_githubissues_ruby3.1.app/Contents/MacOS/klayout",
"bundleInfo" : {"CFBundleShortVersionString":"0.28.11","CFBundleVersion":"0.28.11","CFBundleIdentifier":"de.klayout"},
"storeInfo" : {"deviceIdentifierForVendor":"72DB6EA9-008B-5787-9068-6D977E2334E1","thirdParty":true},
"parentProc" : "launchd",
"parentPid" : 1,
"coalitionName" : "de.klayout",
"crashReporterKey" : "612438D0-5FCF-B469-5D0D-17FBD3BA95A2",
"codeSigningID" : "",
"codeSigningTeamID" : "",
"codeSigningFlags" : 16777728,
"codeSigningValidationCategory" : 0,
"codeSigningTrustLevel" : 0,
"wakeTime" : 2339,
"sleepWakeUUID" : "B18F561C-2842-483B-B432-DAB77A3388E4",
"sip" : "enabled",
"vmRegionInfo" : "0x10265c000 is in 0x10265c000-0x10266c000; bytes after start: 0 bytes before end: 65535\n REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> __TEXT 10265c000-10266c000 [ 64K] r-x/r-x SM=COW \n __DATA_CONST 10266c000-102670000 [ 16K] rw-/rw- SM=COW ",
"exception" : {"codes":"0x0000000000000032, 0x000000010265c000","rawCodes":[50,4335190016],"type":"EXC_BAD_ACCESS","signal":"SIGKILL (Code Signature Invalid)","subtype":"UNKNOWN_0x32 at 0x000000010265c000"},
"termination" : {"flags":0,"code":2,"namespace":"CODESIGNING","indicator":"Invalid Page"},
"vmregioninfo" : "0x10265c000 is in 0x10265c000-0x10266c000; bytes after start: 0 bytes before end: 65535\n REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL\n UNUSED SPACE AT START\n---> __TEXT 10265c000-10266c000 [ 64K] r-x/r-x SM=COW \n __DATA_CONST 10266c000-102670000 [ 16K] rw-/rw- SM=COW ",
"extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
"faultingThread" : 0,
"threads" : [{"triggered":true,"id":8312367,"threadState":{"x":[{"value":4335190016},{"value":6131693608},{"value":6131693520},{"value":4339097134},{"value":117},{"value":117},{"value":0},{"value":2624},{"value":6131693576},{"value":4339692848,"symbolLocation":0,"symbol":"__block_descriptor_tmp.57"},{"value":4339605504,"symbolLocation":4,"symbol":"lsl::Vector::reserveExact(unsigned long) (.cold.1)"},{"value":4339657145},{"value":101},{"value":115},{"value":352848},{"value":0},{"value":4339106412,"symbolLocation":0,"symbol":"invocation function for block in dyld3::MachOFile::forEachSupportedPlatform(void (dyld3::Platform, unsigned int, unsigned int) block_pointer) const"},{"value":7701436843911952336},{"value":0},{"value":6131693608},{"value":4335190016},{"value":6131693520},{"value":6131694088},{"value":6131694048},{"value":6131693920},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":1804676817519477196},"cpsr":{"value":2147487744},"fp":{"value":6131693504},"sp":{"value":6131693360},"esr":{"value":2449473543,"description":"(Data Abort) byte read Translation fault"},"pc":{"value":4339098084,"matchesCrashFrame":1},"far":{"value":4335190016}},"frames":[{"imageOffset":8676,"symbol":"dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const","symbolLocation":52,"imageIndex":0},{"imageOffset":16844,"symbol":"dyld3::MachOFile::forEachSupportedPlatform(void (dyld3::Platform, unsigned int, unsigned int) block_pointer) const","symbolLocation":160,"imageIndex":0},{"imageOffset":351756,"symbol":"dyld3::MachOFile::isBuiltForSimulator() const","symbolLocation":124,"imageIndex":0},{"imageOffset":22756,"symbol":"start","symbolLocation":632,"imageIndex":0}]}],
"usedImages" : [
{
"source" : "P",
"arch" : "arm64e",
"base" : 4339089408,
"size" : 589824,
"uuid" : "e7a99595-e0f8-34af-be8b-9347d0d658a4",
"name" : ""
},
{
"source" : "P",
"arch" : "arm64",
"base" : 4335190016,
"size" : 65536,
"uuid" : "05fef845-122a-3dfb-a85c-d8c319218603",
"name" : ""
}
],
"vmSummary" : "ReadOnly portion of Libraries: Total=1008K resident=0K(0%) swapped_out_or_unallocated=1008K(100%)\nWritable regions: Total=8176K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=8176K(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nSTACK GUARD 56.0M 1 \nStack 8176K 1 \n__DATA 32K 2 \n__DATA_CONST 48K 2 \n__DATA_DIRTY 16K 1 \n__LINKEDIT 368K 2 \n__TEXT 640K 2 \n=========== ======= ======= \nTOTAL 65.1M 11 \n",
"legacyInfo" : {
"threadTriggered" : {

}
},
"logWritingSignature" : "5d566bcdea09d69e13d50cab181d0af31af46511",
"trialInfo" : {
"rollouts" : [
{
"rolloutId" : "60186475825c62000ccf5450",
"factorPackIds" : {

  },
  "deploymentId" : 240000062
},
{
  "rolloutId" : "61675b89201f677a9a4cbd65",
  "factorPackIds" : {
    "HEALTH_FEATURE_AVAILABILITY" : "64d14f3e1008ca2fac17a163"
  },
  "deploymentId" : 240000068
}

],
"experiments" : [
{
"treatmentId" : "6dd670af-0633-45e4-ae5f-122ae4df02be",
"experimentId" : "64406ba83deb637ac8a04419",
"deploymentId" : 900000017
},
{
"treatmentId" : "3a3cf641-8471-4e4e-9ad4-81d0ede970fd",
"experimentId" : "64a84dae90d82611a0bd7d3d",
"deploymentId" : 400000010
}
]
},
"reportNotes" : [
"dyld_process_snapshot_get_shared_cache failed"
]
}

Model: MacBookAir10,1, BootROM 8422.141.2, proc 8:4:4 processors, 8 GB, SMC
Graphics: Apple M1, Apple M1, Built-In
Display: Color LCD, 2560 x 1600 Retina, Main, MirrorOff, Online
Memory Module: LPDDR4, Hynix
AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x4378), wl0: May 13 2023 07:20:48 version 18.20.383.15.7.8.150 FWID 01-b37727a5
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB31Bus
USB Device: USB31Bus
Thunderbolt Bus: MacBook Air, Apple Inc.
Thunderbolt Bus: MacBook Air, Apple Inc.

@stefanottili
Copy link

I've never seen the issue you're facing.

I'm using homebrew to get the dependencies.
Running the latest MacOS Ventura 13.5.2, but that shouldn't matter:
I've been building klayout on my MacBook M1 since it came out.

build4mac.py -r HB32 -p HBAuto -q Qt5Brew -m '--jobs=8' -n -u

worked for me just a couple minutes ago and it run's without issues.
I don't need the bindings, so I use -n -u.

@klayoutmatthias
Copy link
Collaborator

A quick search gives me this: https://developer.apple.com/forums/thread/130313

But I can't help further. MacOS is not my home turf.

Matthias

@Kazzz-S
Copy link
Contributor

Kazzz-S commented Sep 12, 2023

I have extended the build system for Mac in response to someone's request to build KLayout on Apple silicon.
However, I do not have an M1 Mac and have not tested it by myself. My apologies :-(

As @stefanottili attempted above, M1 Mac users are supposed to use Homebrew installed in the default directory below.

# File: "macbuild/build4mac_env.py"
:
:
if Machine == "arm64": # Apple Silicon!
  DefaultHomebrewRoot = '/opt/homebrew'
else:
  DefaultHomebrewRoot = '/usr/local'
:
:

Kazzz-S

@thomaslima
Copy link
Collaborator

thomaslima commented Sep 12, 2023 via email

@jasminabrar
Copy link
Author

Thank you everyone for your suggestions. It is strange that building isn't working for me but is working on other Mac M1 Ventura. I am currently exploring issue 50 and will report back with my findings.

@jasminabrar
Copy link
Author

@stefanottili What version of KLayout are you building? Lukas is also having issues with KLayout crashing when building the 0.28.12, however he can successfully build 0.28.5.

@stefanottili
Copy link

stefanottili commented Sep 15, 2023

I'm always building master, which as of Sept14 is at the 0.28.12 tag.
I've never encountered the crashes Lukas is seeing since I got my 2020 M1 MacBook (16GB).

But I've also never "moved" or "packaged" the klayout bin directory.
I'm running klayout using the following script, setting DYLD_LIBRARY_PATH and the calling klayout where it's built.

more ~/bin/klayout
export DYLD_LIBRARY_PATH=/Users/user/klayout/qt5Brew.bin.macos-Ventura-release-Rhb32Phbauto:/Users/user/klayout/qt5Brew.bin.macos-Ventura-release-Rhb32Phbauto/db_plugins:/Users/user/klayout/qt5Brew.bin.macos-Ventura-release-Rhb32Phbauto/lay_plugins
/Users/user/klayout/qt5Brew.bin.macos-Ventura-release-Rhb32Phbauto/klayout.app/Contents/MacOS/klayout $@

@dsus4wang
Copy link

just use "sudo" to build

@thomaslima
Copy link
Collaborator

For the love of me I am not able to build a HW version of the klayout app on my M2 Mac (Sonoma). The best I was able to do was a LW version, which requires all brew dependencies to be installed (libgit2, qt@5, [email protected] etc.). That's what I am going to equip on a personal level.

The macdeployqt tool is not able to properly codesign a version of the app that can pass the Gatekeeper (even with no python and no ruby). Given that the error doesn't occur with the LW version, the culprit must be in the mac deployment step of qt. I will try again once the migration to Qt6 is complete.

If anyone is curious I did the following:

  • brew install ccache qt@5 [email protected] libgit2 libpng (I might have forgotten something here)
  • cloned klayout (I'm on kazzz/wip-mac-master's branch, commit SHA f57d2cb)
  • build with QMAKE_CCACHE=1 ./build4mac.py -m --jobs=8 -r nil (the ccache speeds up rebuilds in the future)
  • make LW app with QMAKE_CCACHE=1 ./build4mac.py -m --jobs=8 -r nil -Y (I'm not sure if my edit below is required for the LW version)
  • copy LW-qt5Brew.pkg.macos-Sonoma-release-RnilPhb311/klayout.app to my /Applications folder
  • This will use python 3.11 installed in /opt/homebrew/Cellar/[email protected]

@Kazzz-S I found that the QMAKE_APPLE_DEVICE_ARCHS=arm64 environment variable is required for the Apple Silicon (It's possible Qt6 will have fixed that though). I have added the following lines to your script:

@@ -133,7 +134,8 @@ def Get_Default_Config():
         if Machine == "arm64" and Platform in ["Sonoma", "Ventura", "Monterey"]: # with an Apple Silicon Chip
             print("")
             print( "### Your Mac equips an Apple Silicon Chip ###" )
-            print("")
+            print("Setting QMAKE_APPLE_DEVICE_ARCHS=arm64\n")
+            os.environ['QMAKE_APPLE_DEVICE_ARCHS'] = 'arm64'

@Kazzz-S
Copy link
Contributor

Kazzz-S commented Nov 13, 2023

@thomaslima Thanks for testing my wip-mac-master branch. Also, the change requested above.
I'll add the lines to the build4mac.py script.

Kazzz-S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants