Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.67k stars 307 forks source link

rawtherapee-cli 5.9 release always crashes on macOS M1 arm64 #6736

Open isenberg opened 1 year ago

isenberg commented 1 year ago

Short description Running rawtherapee-cli in Terminal.app always crashes. The desktop application rawtherapee works fine, also when started from the same Terminal.app.

Steps to reproduce Download from https://rawtherapee.com/shared/builds/mac/RawTherapee_macOS_11.7_Universal_5.9.zip and install.

% /Applications/RawTherapee.app/Contents/Frameworks/rawtherapee-cli 
zsh: trace trap  /Applications/RawTherapee.app/Contents/Frameworks/rawtherapee-cli

% /Applications/RawTherapee.app/Contents/Frameworks/rawtherapee-cli -h
zsh: trace trap  /Applications/RawTherapee.app/Contents/Frameworks/rawtherapee-cli -h

Expected behavior rawtherapee-cli runs in Terminal.app It did that successfully in earlier versions on the same M1 mac, though on an earlier macOS like 13.1, I guess it 5.9-dev from github.

Additional information

 % /Applications/RawTherapee.app/Contents/MacOS/rawtherapee -v
RawTherapee, version 5.9

% sw_vers 
ProductName:        macOS
ProductVersion:     13.2.1
BuildVersion:       22D68

% uname -a
Darwin gloster.attlocal.net 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:35 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T8103 arm64
isenberg commented 1 year ago

When building it from source, it works fine on the same system:

% git clone -b 5.9 https://github.com/Beep6581/RawTherapee.git
% brew install gtk+3 gtkmm3 gtk-mac-integration adwaita-icon-theme libsigc++ little-cms2 libiptcdata fftw lensfun wget llvm cmake expat pkgconfig shared-mime-info libomp
% cd RawTherapee
% mkdir build
% cd build
% cmake -DPROC_TARGET_NUMBER="2" -DCMAKE_BUILD_TYPE="release" -DCACHE_NAME_SUFFIX="5.9" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DWITH_LTO="OFF" -DLENSFUNDBDIR="share/lensfun" -DCMAKE_OSX_DEPLOYMENT_TARGET=13.2.1 -DLOCAL_PREFIX:STRING="/opt/homebrew" -DCMAKE_OSX_ARCHITECTURES=arm64 ..
% make -j$(sysctl -n hw.ncpu) install
% ./build/release/MacOS/rawtherapee-cli -v
RawTherapee, version 5.9, command line.
[...]
isenberg commented 1 year ago

While trying to run it with dtruss and enabling access to it via https://developer.apple.com/forums/thread/694233 I found out that the additional code signature for that also solves the crash. Originally after copying rawtherapee-cli to a different directory, it still crashes. But after applying the debug signatur, it works:


% cp /Applications/RawTherapee.app/Contents/Frameworks/rawtherapee-cli  .
% ./rawtherapee-cli -h                                                                                               
zsh: trace trap  ./rawtherapee-cli -h
% /usr/libexec/PlistBuddy -c "Add :com.apple.security.get-task-allow bool true" /tmp/entitlements
% codesign -s - -f --entitlements /tmp/entitlements rawtherapee-cli
rawtherapee-cli: replacing existing signature
% ./rawtherapee-cli -h                                             
RawTherapee, version 5.9, command line.
[...]
Benitoite commented 11 months ago

Thanks for the report. PR https://github.com/Beep6581/RawTherapee/pull/6796 fixes the issue in the bundle script.

RawTherapee_macOS_13.3_Universal_5.9-260-gc557b320c_folder/rawtherapee-cli ; exit;
RawTherapee, version 5.9-260-gc557b320c, command line.
Terminating without anything to do.

New macOS builds with updated libomp 16+

now available in my iCloud shared drive:

If you can test, please let us know if it works for you. If you are seeking help on your own build system, please include the complete AboutThisBuild.txt.

My working systems:

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.5.0
Thread model: posix
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
isenberg commented 11 months ago

Thanks. I tried the dev versions now: The rawtherapee-cli inside the DMG exits with the same trap as previously:

% /Applications/RawTherapee.app/Contents/MacOS/rawtherapee -v RawTherapee, version 5.9-218-g4f752154c % /Applications/RawTherapee.app/Contents/MacOS/rawtherapee-cli zsh: trace trap /Applications/RawTherapee.app/Contents/MacOS/rawtherapee-cli

Testing the rawtherapee-cli directly inside the ZIP most likely doesn't make sense for me as it's not signed. While I could sign it myself it won't help other users who just download the public RT release later:

“rawtherapee-cli” cannot be opened because the developer cannot be verified.

My own build system works fine at least for my local purpose to just being able to run rawtherapee-cli. The bug report is more a request to make it usable also for other users.

Benitoite commented 11 months ago

Thanks for the report. However, PR https://github.com/Beep6581/RawTherapee/pull/6796 fixes the issue in the bundle script by adding an ad hoc code signature to the -cli in the zip. Keeping the cli in the bundle is no longer supported. If ad hoc is not enough for the outer -cli I will add my team ID. This actually may now be required in Ventura due to security changes.

Benitoite commented 11 months ago

With PR #6816 the -cli signature is now certified. Renewed builds to follow.

jrhizor commented 6 months ago

I'm running into this issue still for both the Homebrew and website DMG download installs on macOS 13.6.2 (M1).

Benitoite commented 6 months ago

I'm running into this issue still for both the Homebrew and website DMG download installs on macOS 13.6.2 (M1). @jrhizor What do you mean by "the Homebrew", and which website? Are you still testing 5.9? That is way too old... Have you tested a recent build, as in https://r42.us/rt5

jrhizor commented 6 months ago

I installed via brew install rawtherapee, which uses 5.9 (it downloads 889489018e80ab6dc9e69790a9b0b7dc097686a49cfce9f4a9ec5c66de9020aa--RawTherapee_macOS_11.7_Universal_5.9.zip). I thought it was the most recent since 5.9 the latest published release here on GitHub and on the website.

Thanks, the recent build works!

And thanks for the reply btw (especially around the holidays), I really appreciate it!

dsmurrell commented 2 months ago

Not working for me:

➜  brew install rawtherapee
==> Downloading https://www.rawtherapee.com/shared/builds/mac/RawTherapee_macOS_13.3_Universal_5.10.zip
Already downloaded: /Users/getafix/Library/Caches/Homebrew/downloads/cb5896b4dc730ca4734983a90cdb8f62f8b8c2c8cd3bc490c3abe0c8058019df--RawTherapee_macOS_13.3_Universal_5.10.zip
==> Installing Cask rawtherapee
==> Moving App 'RawTherapee.app' to '/Applications/RawTherapee.app'

And got the cli tool from the download of 5.10 on the website.

What do I need to change to avoid the trap 20114 trace trap rawtherapee-cli -v -o output.jpg -p profile.pp3 -c 172A2023.CR3

isenberg commented 2 months ago

As workaround until it is fixed you could build rawtherapee from source. That's simply this, copied from my previous comment from some months ago. Maybe you need to replace 5.9 now with 5.10:

git clone -b 5.9 https://github.com/Beep6581/RawTherapee.git
brew install gtk+3 gtkmm3 gtk-mac-integration adwaita-icon-theme libsigc++ little-cms2 libiptcdata fftw lensfun wget llvm cmake expat pkgconfig shared-mime-info libomp
cd RawTherapee
mkdir build
cd build
cmake -DPROC_TARGET_NUMBER="2" -DCMAKE_BUILD_TYPE="release" -DCACHE_NAME_SUFFIX="5.9" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DWITH_LTO="OFF" -DLENSFUNDBDIR="share/lensfun" -DCMAKE_OSX_DEPLOYMENT_TARGET=13.2.1 -DLOCAL_PREFIX:STRING="/opt/homebrew" -DCMAKE_OSX_ARCHITECTURES=arm64 ..
make -j$(sysctl -n hw.ncpu) install
./build/release/MacOS/rawtherapee-cli -v
Lawrence37 commented 2 months ago

@dsmurrell Are you able to run the cli through a debugger (gdb or lldb) and see what it outputs?