ahrm / sioyek

Sioyek is a PDF viewer with a focus on textbooks and research papers
https://sioyek.info/
GNU General Public License v3.0
7.23k stars 236 forks source link

Namespace CODESIGNING, Code 2 Invalid Page #806

Open zzj0402 opened 1 year ago

zzj0402 commented 1 year ago

I am following the "install from source" guide to test build on my m1 Macbook Air. It builds successfully but the app would not run:

Process:               sioyek [12285]
Path:                  /Users/USER/*/sioyek.app/Contents/MacOS/sioyek
Identifier:            info.sioyek.sioyek
Version:               2.0 (???)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-08-31 13:24:04.8318 +1200
OS Version:            macOS 13.0.1 (22A400)
Report Version:        12
Anonymous UUID:        2A0F1669-7110-72E1-1285-9BF991970FD1

Sleep/Wake UUID:       9C198CED-71CF-4EE1-8496-A37431C83C6E

Time Awake Since Boot: 730000 seconds
Time Since Wake:       3693 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
Exception Codes:       UNKNOWN_0x32 at 0x0000000102ddc000
Exception Codes:       0x0000000000000032, 0x0000000102ddc000

Termination Reason:    Namespace CODESIGNING, Code 2 Invalid Page
ahrm commented 1 year ago

I don't have a mac device right now, so I can't help you much, but I remember having this issue when I tried to compile on a mac, I don't exactly remember how I fixed it though. MacOS requires the executable to be signed to execute. I think executing the raw sioyek executable (instead of the packaged app) works if I remember correctly.

zzj0402 commented 1 year ago

I don't have a mac device right now, so I can't help you much, but I remember having this issue when I tried to compile on a mac, I don't exactly remember how I fixed it though. MacOS requires the executable to be signed to execute. I think executing the raw sioyek executable (instead of the packaged app) works if I remember correctly.

What do you mean by "raw sioyek executable (instead of the packaged app)"? In the build fold, there is only one .app which requires signing.

% codesign --sign - sioyek.app
sioyek.app: code object is not signed at all
In subcomponent: build/sioyek.app/Contents/MacOS/keys_user.config
zzj0402 commented 1 year ago

I managed to sign the app with:

codesign --force --deep --sign - sioyek.app

But it is asking for libpng in a location that doesn't exist:

'/usr/lib/libpng16.16.dylib' (no such file, not in dyld cache)Library not loaded: @loader_path/../../../../../../../opt/pcre2/lib/libpcre2-16.0.dylib

Is this hardcoded in a script somewhere?

The locally build version:

/build/sioyek.app/Contents/MacOS/sioyek ; exit;
dyld[1065]: Library not loaded: @loader_path/../../../../../../../opt/libpng/lib/libpng16.16.dylib

As a comparison, the publicly released version:

Desktop/sioyek.app/Contents/MacOS/sioyek ; exit;
default_config_path: /Users/zingg/Desktop/sioyek.app/Contents/MacOS/prefs.config
default_keys_path: /Users/zingg/Desktop/sioyek.app/Contents/MacOS/keys.config
user_config_path: [ 0 ] /Users/zingg/.config/sioyek/prefs_user.config
user_config_path: [ 1 ] /Users/zingg/Library/Application Support/sioyek/prefs_user.config
user_keys_path: [ 0 ] /Users/zingg/.config/sioyek/keys_user.config
user_keys_path: [ 1 ] /Users/zingg/Library/Application Support/sioyek/keys_user.config
database_file_path: /Users/zingg/Library/Application Support/sioyek/test.db
local_database_file_path: /Users/zingg/Library/Application Support/sioyek/local.db
global_database_file_path: /Users/zingg/Library/Application Support/sioyek/shared.db
tutorial_path: /Users/zingg/Desktop/sioyek.app/Contents/MacOS/tutorial.pdf
last_opened_file_address_path: /Users/zingg/Library/Application Support/sioyek/last_document_path.txt
shader_path: /Users/zingg/Desktop/sioyek.app/Contents/MacOS/shaders
Creating shared memory block...
Shared memory created: this is the primary application.
Starting IPC server...
IPC server started.
ahrm commented 1 year ago

In the build fold, there is only one .app which requires signing.

You can open the .app like a directory and find the executable inside.