[BUG] tools/mkimage is broken on macos arm64

Sergey V. Lobanov sergey at lobanov.in
Tue Nov 30 12:49:46 CET 2021


Hello,

I have observed that u-boot mkimage is broken on macos arm64, it generates segfault every time.

Reproducing:

My MacOS environment:
% sw_vers             
ProductName:	macOS
ProductVersion:	11.6
BuildVersion:	20G165

% uname -s -r -m 
Darwin 20.6.0 arm64

1. Build on macos arm64
% export CPATH=/opt/homebrew/opt/openssl at 1.1/include
% export LIBRARY_PATH=/opt/homebrew/opt/openssl at 1.1/lib
% make tools

2. Versions
% git log | head -n 1
commit ade37460a944aed36ae6ee634c4d4a9a22690461

% ./mkimage -V         
mkimage version 2022.01-rc3

3. Run
% ./mkimage -f aaa bbb
zsh: segmentation fault  ./mkimage -f aaa bbb

(Diagnostics related to the segfault attached)

The same story for Mac homebrew’s version:

% mkimage -V         
mkimage version 2021.10
% mkimage -f aaa bbb
zsh: segmentation fault  mkimage -f aaa bbb


If do the same on normal Linux host, everything is ok (no segfault):

$ uname -s -r -m 
Linux 4.19.0-18-amd64 x86_64

$ ./mkimage -V
mkimage version 2022.01-rc3

$ ./mkimage -f aaa bbb
FATAL ERROR: Couldn't open "aaa": No such file or directory
./mkimage: Can't open bbb.tmp: No such file or directory


-------------- next part --------------
Process:               mkimage [66390]
Path:                  /Volumes/VOLUME/*/mkimage
Identifier:            mkimage
Version:               0
Code Type:             ARM-64 (Native)
Parent Process:        zsh [66066]
Responsible:           Terminal [509]
User ID:               501

Date/Time:             2021-11-30 13:26:45.135 +0300
OS Version:            macOS 11.6 (20G165)
Report Version:        12
Anonymous UUID:        8B96688F-4FA4-4F0B-BDF2-8C701B568415

Sleep/Wake UUID:       B3FEC8EC-A9D2-4D40-9039-F3FB897CBFD0

Time Awake Since Boot: 63000 seconds
Time Since Wake:       15000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000100041e48
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [66390]

VM Regions Near 0x100041e48:
--> 
    __TEXT                      1001ac000-1001e8000    [  240K] r-x/r-x SM=COW  /Volumes/*

Application Specific Information:
dyld2 mode

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   mkimage                       	0x00000001001b8194 imagetool_get_type + 104
1   mkimage                       	0x00000001001b8158 imagetool_get_type + 44

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000100041e48   x1: 0x00000001001dc8ea   x2: 0x0000000000000010   x3: 0xfffffffffffffff6
    x4: 0x0000000000000000   x5: 0x0000000000000000   x6: 0x0000000000000000   x7: 0x0000000000000720
    x8: 0x0000000100041f18   x9: 0x0000000100388000  x10: 0x00000000000007b2  x11: 0x000000020347269e
   x12: 0x000000020347269e  x13: 0x0000000000000052  x14: 0x0000000000000881  x15: 0x000000008000001f
   x16: 0x000000018c31fd90  x17: 0x00000001fb4752e0  x18: 0x0000000000000000  x19: 0x0000000100041e48
   x20: 0x0000000000000008  x21: 0x00000000000000d0  x22: 0x0000000000000004  x23: 0x00000001001ed000
   x24: 0x000000016fc53710  x25: 0x00000001001edda0  x26: 0x00000001001e2bae  x27: 0x0000000000000000
   x28: 0x000000016fc53820   fp: 0x000000016fc53810   lr: 0x22298001001b8158
    sp: 0x000000016fc53680   pc: 0x00000001001b8194 cpsr: 0x80000000
   far: 0x0000000100041e48  esr: 0x92000007


Binary Images:
       0x1001ac000 -        0x1001e7fff +mkimage (0) <837B3404-C3BF-35E9-9856-76FFDEAEC692> /Volumes/VOLUME/*/mkimage
       0x1003a4000 -        0x1003effff +libssl.1.1.dylib (0) <1810A984-9AC7-32AD-BC73-81DFBB9CA650> /opt/homebrew/*/libssl.1.1.dylib
       0x1004b8000 -        0x100537fff  dyld (852.2) <38657979-1ABE-3C9A-BF64-EF3B746216AB> /usr/lib/dyld
       0x1005c0000 -        0x10073ffff +libcrypto.1.1.dylib (0) <F1AC371A-7962-3E51-8540-D042B52ACC61> /opt/homebrew/*/libcrypto.1.1.dylib
       0x18c032000 -        0x18c033fff  libsystem_blocks.dylib (79) <BA713F79-1620-38B2-8717-79849B8E897E> /usr/lib/system/libsystem_blocks.dylib
       0x18c034000 -        0x18c06bfff  libxpc.dylib (2038.120.1) <0E990C5D-C4F7-304A-9714-4409647CC2EF> /usr/lib/system/libxpc.dylib
       0x18c06c000 -        0x18c083fff  libsystem_trace.dylib (1277.120.1) <7A6B4800-8D94-3091-AC78-2D6B97A9B496> /usr/lib/system/libsystem_trace.dylib
       0x18c084000 -        0x18c0f7fff  libcorecrypto.dylib (1000.140.4) <FAF9B49D-2583-34EF-850B-047F050ED996> /usr/lib/system/libcorecrypto.dylib
       0x18c0f8000 -        0x18c123fff  libsystem_malloc.dylib (317.140.5) <A454F3F2-7BC4-3808-A60F-F5F4BC55577F> /usr/lib/system/libsystem_malloc.dylib
       0x18c124000 -        0x18c168fff  libdispatch.dylib (1271.120.2) <4EDD5F72-2296-3891-B2A1-6741DB6C05C9> /usr/lib/system/libdispatch.dylib
       0x18c169000 -        0x18c1a2fff  libobjc.A.dylib (824) <252C93CC-2D39-3C15-87F6-1336658B2F49> /usr/lib/libobjc.A.dylib
       0x18c1a3000 -        0x18c1a5fff  libsystem_featureflags.dylib (28.60.1) <61A79E0B-1836-376D-AC24-171B40A9FAE7> /usr/lib/system/libsystem_featureflags.dylib
       0x18c1a6000 -        0x18c227fff  libsystem_c.dylib (1439.141.1) <9B3C0AD0-1E0B-39D1-BE25-B97F8EA7E623> /usr/lib/system/libsystem_c.dylib
       0x18c228000 -        0x18c283fff  libc++.1.dylib (905.6) <BED05B96-CCAE-365A-B3F5-F8D72F5E77E1> /usr/lib/libc++.1.dylib
       0x18c284000 -        0x18c29bfff  libc++abi.dylib (905.6) <3C5176E2-CE48-312B-97F6-23D4E7AFA43F> /usr/lib/libc++abi.dylib
       0x18c29c000 -        0x18c2cffff  libsystem_kernel.dylib (7195.141.6) <FA7E835C-CB30-3D98-9331-30CE6584423D> /usr/lib/system/libsystem_kernel.dylib
       0x18c2d0000 -        0x18c2dcfff  libsystem_pthread.dylib (454.120.2) <BDC1C5DA-9499-3580-9588-2928DE2440DD> /usr/lib/system/libsystem_pthread.dylib
       0x18c2dd000 -        0x18c31efff  libdyld.dylib (852.2) <BE0B539A-2EDF-3A99-9632-731C5928BBAC> /usr/lib/system/libdyld.dylib
       0x18c31f000 -        0x18c325fff  libsystem_platform.dylib (254.80.2) <2CC11FAD-1E31-3533-B1D8-9CDDF5DFE595> /usr/lib/system/libsystem_platform.dylib
       0x18c326000 -        0x18c351fff  libsystem_info.dylib (542.40.3) <3B5B9F97-ECFB-3F6E-9B85-D8C62A8B3205> /usr/lib/system/libsystem_info.dylib
       0x18e6e7000 -        0x18e6f1fff  libsystem_darwin.dylib (1439.141.1) <9BF54A49-874D-3D91-B319-6B2F676FE42D> /usr/lib/system/libsystem_darwin.dylib
       0x18eb2a000 -        0x18eb35fff  libsystem_notify.dylib (279.40.4) <FA85C044-99A5-352D-B7AD-45FB31B295FF> /usr/lib/system/libsystem_notify.dylib
       0x190b09000 -        0x190b18fff  libsystem_networkextension.dylib (1295.140.3) <0FFACDE5-D546-306D-B9FA-06EC8FCAEEF9> /usr/lib/system/libsystem_networkextension.dylib
       0x190b6e000 -        0x190b85fff  libsystem_asl.dylib (385) <7F462B8A-541F-3195-9BAE-CDEDFA3BA8A4> /usr/lib/system/libsystem_asl.dylib
       0x1920df000 -        0x1920e6fff  libsystem_symptoms.dylib (1431.140.1) <0B4FC817-CC87-31F2-872B-BD505D29F5EE> /usr/lib/system/libsystem_symptoms.dylib
       0x193f3b000 -        0x193f4cfff  libsystem_containermanager.dylib (318.100.4) <FCE2D8EA-A9D8-3A5D-A908-3E9C0AFFB941> /usr/lib/system/libsystem_containermanager.dylib
       0x194bb9000 -        0x194bbdfff  libsystem_configuration.dylib (1109.140.1) <9BC511C4-6613-3F1D-8592-7D3971B24921> /usr/lib/system/libsystem_configuration.dylib
       0x194bbe000 -        0x194bc2fff  libsystem_sandbox.dylib (1441.141.4) <CABF63A0-DDAF-3A54-8447-1256DFFD2907> /usr/lib/system/libsystem_sandbox.dylib
       0x19557f000 -        0x195581fff  libquarantine.dylib (119.40.2) <DE9BFFD7-62ED-38ED-BF58-388F192BE6FC> /usr/lib/system/libquarantine.dylib
       0x195ae2000 -        0x195ae6fff  libsystem_coreservices.dylib (127.1) <F107780A-EFAD-3DC8-A62F-825DD954128E> /usr/lib/system/libsystem_coreservices.dylib
       0x195cde000 -        0x195d0bfff  libsystem_m.dylib (3186.100.3) <092A6565-3BE3-3EEF-844E-B846793A4115> /usr/lib/system/libsystem_m.dylib
       0x195d0d000 -        0x195d12fff  libmacho.dylib (980) <F6CBC87D-DC83-3E5F-A7C0-B0115E7D1BC1> /usr/lib/system/libmacho.dylib
       0x195d2b000 -        0x195d38fff  libcommonCrypto.dylib (60178.120.3) <146E6A52-3060-32A1-9119-C3D6F8B5C57B> /usr/lib/system/libcommonCrypto.dylib
       0x195d39000 -        0x195d43fff  libunwind.dylib (201) <2A01EF92-F92D-35F7-B638-8CBC6896DCAA> /usr/lib/system/libunwind.dylib
       0x195d44000 -        0x195d4bfff  liboah.dylib (203.58) <6802DEC1-9ED5-3667-BFE0-3BDDE8BB40E1> /usr/lib/liboah.dylib
       0x195d4c000 -        0x195d54fff  libcopyfile.dylib (173.40.2) <8477DD43-56AA-3422-BF23-4ADC7B98462F> /usr/lib/system/libcopyfile.dylib
       0x195d55000 -        0x195d58fff  libcompiler_rt.dylib (102.2) <50E8F23E-3E63-31BF-BFC3-EE75D281B151> /usr/lib/system/libcompiler_rt.dylib
       0x195d59000 -        0x195d5bfff  libsystem_collections.dylib (1439.141.1) <EA89016C-2C72-3531-84D9-2A696F2DAC85> /usr/lib/system/libsystem_collections.dylib
       0x195d5c000 -        0x195d5efff  libsystem_secinit.dylib (87.60.1) <836B23E3-DF08-31C8-98AD-4A9B12A4B404> /usr/lib/system/libsystem_secinit.dylib
       0x195d5f000 -        0x195d61fff  libremovefile.dylib (49.120.1) <687A6E36-0460-30BC-A675-7F83059AE2D9> /usr/lib/system/libremovefile.dylib
       0x195d62000 -        0x195d62fff  libkeymgr.dylib (31) <C5D64EE9-AB76-3D4C-BC4F-2BE8415DC21A> /usr/lib/system/libkeymgr.dylib
       0x195d63000 -        0x195d6bfff  libsystem_dnssd.dylib (1310.140.1) <DEE0783F-DDC9-35A6-9F6E-6B8FE94FBF0A> /usr/lib/system/libsystem_dnssd.dylib
       0x195d6c000 -        0x195d71fff  libcache.dylib (83) <2EA812B3-0565-35FA-BF54-DF98EF3DB5DE> /usr/lib/system/libcache.dylib
       0x195d72000 -        0x195d73fff  libSystem.B.dylib (1292.120.1) <1E75FCDF-2357-30FE-AAAD-5290BA722464> /usr/lib/libSystem.B.dylib
       0x199191000 -        0x199191fff  liblaunch.dylib (2038.120.1) <AA4E8477-1B82-357E-8275-FFED1F957AF9> /usr/lib/system/liblaunch.dylib
       0x19b645000 -        0x19b645fff  libsystem_product_info_filter.dylib (8.40.1) <14136F56-3690-3346-90A0-31FC34DF3E1B> /usr/lib/system/libsystem_product_info_filter.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: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=497.4M resident=0K(0%) swapped_out_or_unallocated=497.4M(100%)
Writable regions: Total=19.0M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=19.0M(100%)
 
                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                   32K        1 
MALLOC                            9360K        8 
MALLOC guard page                   96K        5 
STACK GUARD                       56.0M        1 
Stack                             8176K        1 
VM_ALLOCATE                        1.0G        1 
__AUTH                              45K       11 
__AUTH_CONST                        74K       38 
__DATA                            2098K       41 
__DATA_CONST                       402K       40 
__DATA_DIRTY                        73K       21 
__LINKEDIT                       490.8M        6 
__OBJC_CONST                        10K        5 
__OBJC_RO                         75.1M        1 
__OBJC_RW                         2576K        1 
__TEXT                            6728K       46 
shared memory                       16K        1 
===========                     =======  ======= 
TOTAL                              1.6G      228 



More information about the U-Boot mailing list