UPX compressed arm64/amd64/x86_64 executable crashes on macOS Ventura 13.0
#612 opened on Oct 25, 2022
Repository metrics
- Stars
- (12,842 stars)
- PR merge metrics
- (Avg merge 23h 25m) (18 merged PRs in 30d)
Description
This issue tracker is ONLY used for reporting bugs. Please use stackoverflow for supporting issues.
What's the problem (or question)?
The UPX compressed amd64 executable crashes on macOS 13.0. I made a small CMake project which merely print out a few lines of text for reproducing the crash.
Here are the commands I used to compress the executable. Then it crashed immediately after I ran the compressed one.
% upx -vk ./HelloUPX4 -o./HelloUPX4-compressed
Ultimate Packer for eXecutables
Copyright (C) 1996 - 2020
UPX 3.96 Markus Oberhumer, Laszlo Molnar & John Reiser Jan 23rd 2020
File size Ratio Format Name
-------------------- ------ ----------- -----------
82304 -> 12304 14.95% macho/amd64 HelloUPX4-compressed
Packed 1 file.
% ./HelloUPX4-compressed
zsh: segmentation fault ./HelloUPX4-compressed
%
lldb
% lldb ./HelloUPX4-compressed
(lldb) target create "./HelloUPX4-compressed"
Current executable set to '/Users/matt/HelloUPX4/build/Debug/HelloUPX4-compressed' (x86_64).
(lldb) run
Process 14499 launched: '/Users/matt/HelloUPX4/build/Debug/HelloUPX4-compressed' (x86_64)
Process 14499 stopped
* thread #1, stop reason = EXC_BAD_ACCESS (code=1, address=0x21090c000)
frame #0: 0x000000021090c000
error: memory read failed for 0x21090c000
Target 0: (HelloUPX4-compressed) stopped.
(lldb) exit
What should have happened?
It should print the same text as before it was compressed.
This is the output when it is not compressed.
% lldb "HelloUPX4"
(lldb) target create "HelloUPX4"
Current executable set to '/Users/evatu/Work/HelloUPX4/build/Debug/HelloUPX4' (x86_64).
(lldb) run
Process 14516 launched: '/Users/evatu/Work/HelloUPX4/build/Debug/HelloUPX4' (x86_64)
Hello UPX4!
Done.
Process 14516 exited with status = 0 (0x00000000)
Do you have an idea for a solution?
Actually no, but It was working on macOS 12.
How can we reproduce the issue?
I made a tiny CMake project with 16 lines of code for this bug report. It is configured to generate an amd64 executable. (Not arm64)
- Clone the project at https://github.com/chchwy/upx-macos13-crash and go to the folder
mkdir buildcd buildcmake .. -G Xcodecmake --build .upx -vk ./Debug/HelloUPX4 -o./Debug/HelloUPX4-compressed./Debug/HelloUPX4-compressed<= crashed here
Please tell us details about your environment.
- UPX version used (
upx --version): 3.96 (I tried the latest devel4 branch and it doesn't work either) - Host Operating System and version: macOS 13.0 Ventura
- Host CPU architecture: arm64
- Target Operating System and version: same
- Target CPU architecture: amd64 (or called x86_64)