Skip to content

Conversation

i0ntempest
Copy link

Fixes a segfault on arm64 caused by getsectdata giving an invalid pointer.

I'll be honest that I do not know much C or ObjC and this is suggected to me by ChatGPT. I did test this compiled for both arm64 and x86_64 and it works fine.

instead of getsectdata. Fixes a segfault on arm64 caused by getsectdata giving an invalid pointer.
@i0ntempest
Copy link
Author

FYI, crash log:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               dspci [38792]
Path:                  /Users/USER/Downloads/*/dspci
Identifier:            dspci
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        Exited process [38791]
Responsible:           Terminal [28512]
User ID:               0

Date/Time:             2024-10-05 00:28:49.1695 -0400
OS Version:            macOS 15.0.1 (24A348)
Report Version:        12
Anonymous UUID:        C085A648-C423-0BFE-B132-1AB3FE05851B


Time Awake Since Boot: 76000 seconds

System Integrity Protection: disabled

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

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000100011640
Exception Codes:       0x0000000000000001, 0x0000000100011640

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [38792]

VM Region Info: 0x100011640 is not in any region.  Bytes before following region: 76032448
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      104894000-104a0c000    [ 1504K] r-x/r-x SM=COW  /Users/USER/Downloads/*/dspci

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_platform.dylib      	       0x18ba01504 _platform_strlen + 4
1   libsystem_c.dylib             	       0x18b864490 strdup + 28
2   dspci                         	       0x104898524 0x104894000 + 17700
3   dspci                         	       0x1048981f8 0x104894000 + 16888
4   dspci                         	       0x10489e318 0x104894000 + 41752
5   dspci                         	       0x10489e7dc 0x104894000 + 42972
6   dspci                         	       0x10489e9a4 0x104894000 + 43428
7   dspci                         	       0x10489eb48 0x104894000 + 43848
8   dyld                          	       0x18b64c274 start + 2840


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000100011645   x1: 0x0000000100011640   x2: 0x0000000000000010   x3: 0xfffffffffffffff6
    x4: 0x0000000000000000   x5: 0x0000000000000000   x6: 0x0000000000000360   x7: 0x0000000000000190
    x8: 0x00000000001667c7   x9: 0x0000000000000103  x10: 0x00000000002b51a7  x11: 0x0000000000000001
   x12: 0x0000600003f94950  x13: 0x0000000000000000  x14: 0x0100000104a11e61  x15: 0x0000000104a11e60
   x16: 0x000000018ba01500  x17: 0x00000001f0fb43a0  x18: 0x0000000000000000  x19: 0x0000000100011645
   x20: 0x0000000104a11000  x21: 0x0000600003dc8070  x22: 0x0000600003dc40e0  x23: 0x000000016b56b6d8
   x24: 0x000000018b646000  x25: 0x0000000000000000  x26: 0x0000000000000000  x27: 0x0000000000000000
   x28: 0x0000000000000000   fp: 0x000000016b56ac10   lr: 0x000000018b864490
    sp: 0x000000016b56abf0   pc: 0x000000018ba01504 cpsr: 0x80001000
   far: 0x0000000100011640  esr: 0x92000006 (Data Abort) byte read Translation fault

Binary Images:
       0x104894000 -        0x104a0bfff dspci (*) <e1ca898d-52e0-3c0c-b98e-13fcf275aa19> /Users/USER/Downloads/*/dspci
       0x18ba00000 -        0x18ba07fe3 libsystem_platform.dylib (*) <3fac373b-5c41-3c83-8f9f-c9e781e887da> /usr/lib/system/libsystem_platform.dylib
       0x18b862000 -        0x18b8e3ffb libsystem_c.dylib (*) <a63f0ef9-59f1-3976-8a7e-2037cd50c605> /usr/lib/system/libsystem_c.dylib
       0x18b646000 -        0x18b6c8663 dyld (*) <40bedd20-da23-3b70-a9c2-a1c68a738762> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

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: 5
    thread_create: 0
    thread_set_state: 40

VM Region Summary:
ReadOnly portion of Libraries: Total=799.0M resident=0K(0%) swapped_out_or_unallocated=799.0M(100%)
Writable regions: Total=530.5M written=305K(0%) resident=305K(0%) swapped_out=0K(0%) unallocated=530.2M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                   32K        1 
MALLOC                           522.3M       12 
MALLOC guard page                   96K        6 
STACK GUARD                       56.0M        1 
Stack                             8176K        1 
__AUTH                             749K      154 
__AUTH_CONST                      12.4M      289 
__DATA                            3089K      270 
__DATA_CONST                      9889K      290 
__DATA_DIRTY                       460K       92 
__FONT_DATA                        2352        1 
__LINKEDIT                       582.7M        2 
__OBJC_RW                         2353K        1 
__TEXT                           216.3M      299 
__TPRO_CONST                       272K        2 
page table in kernel               305K        1 
shared memory                       32K        1 
===========                     =======  ======= 
TOTAL                              1.4G     1423 



-----------
Full Report
-----------

{"app_name":"dspci","timestamp":"2024-10-05 00:28:49.00 -0400","app_version":"","slice_uuid":"e1ca898d-52e0-3c0c-b98e-13fcf275aa19","build_version":"","platform":1,"share_with_app_devs":1,"is_first_party":1,"bug_type":"309","os_version":"macOS 15.0.1 (24A348)","roots_installed":0,"incident_id":"50D09656-C5B9-4216-ACCB-1CD2706A07F4","name":"dspci"}
{
  "uptime" : 76000,
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 0,
  "deployVersion" : 210,
  "modelCode" : "Mac14,14",
  "coalitionID" : 8631,
  "osVersion" : {
    "train" : "macOS 15.0.1",
    "build" : "24A348",
    "releaseType" : "User"
  },
  "captureTime" : "2024-10-05 00:28:49.1695 -0400",
  "codeSigningMonitor" : 1,
  "incident" : "50D09656-C5B9-4216-ACCB-1CD2706A07F4",
  "pid" : 38792,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2024-10-05 00:28:49.1637 -0400",
  "procStartAbsTime" : 1832337479134,
  "procExitAbsTime" : 1832337608396,
  "procName" : "dspci",
  "procPath" : "\/Users\/USER\/Downloads\/*\/dspci",
  "parentProc" : "Exited process",
  "parentPid" : 38791,
  "coalitionName" : "com.apple.Terminal",
  "crashReporterKey" : "C085A648-C423-0BFE-B132-1AB3FE05851B",
  "responsiblePid" : 28512,
  "responsibleProc" : "Terminal",
  "codeSigningID" : "dspci-55554944e1ca898d52e03c0cb98e13fcf275aa19",
  "codeSigningTeamID" : "",
  "codeSigningFlags" : 570425345,
  "codeSigningValidationCategory" : 10,
  "codeSigningTrustLevel" : 4294967295,
  "instructionByteStream" : {"beforePC":"AagxbiMAJh5AAADLPwAD6yEwg5oAAAGLwANf1h8gA9UfIAPVAex8kg==","atPC":"IADAPcP5\/xBiBME8AgxAkmMAAsthAMA9AByhTgUAABQfIAPVHyAD1Q=="},
  "bootSessionUUID" : "4BEEC3C1-0246-496A-BF8C-8E29D541F741",
  "sip" : "disabled",
  "vmRegionInfo" : "0x100011640 is not in any region.  Bytes before following region: 76032448\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      __TEXT                      104894000-104a0c000    [ 1504K] r-x\/r-x SM=COW  \/Users\/USER\/Downloads\/*\/dspci",
  "exception" : {"codes":"0x0000000000000001, 0x0000000100011640","rawCodes":[1,4295038528],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x0000000100011640"},
  "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":38792},
  "vmregioninfo" : "0x100011640 is not in any region.  Bytes before following region: 76032448\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      __TEXT                      104894000-104a0c000    [ 1504K] r-x\/r-x SM=COW  \/Users\/USER\/Downloads\/*\/dspci",
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":40,"task_for_pid":5},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":2222673,"threadState":{"x":[{"value":4295038533},{"value":4295038528},{"value":16},{"value":18446744073709551606},{"value":0},{"value":0},{"value":864},{"value":400},{"value":1468359},{"value":259},{"value":2838951},{"value":1},{"value":105553182935376},{"value":0},{"value":72057598410563169},{"value":4372635232},{"value":6637491456,"symbolLocation":0,"symbol":"_platform_strlen"},{"value":8337965984},{"value":0},{"value":4295038533},{"value":4372631552},{"value":105553181048944},{"value":105553181032672},{"value":6095812312},{"value":6633578496},{"value":0},{"value":0},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6635799696},"cpsr":{"value":2147487744},"fp":{"value":6095809552},"sp":{"value":6095809520},"esr":{"value":2449473542,"description":"(Data Abort) byte read Translation fault"},"pc":{"value":6637491460,"matchesCrashFrame":1},"far":{"value":4295038528}},"queue":"com.apple.main-thread","frames":[{"imageOffset":5380,"symbol":"_platform_strlen","symbolLocation":4,"imageIndex":1},{"imageOffset":9360,"symbol":"strdup","symbolLocation":28,"imageIndex":2},{"imageOffset":17700,"imageIndex":0},{"imageOffset":16888,"imageIndex":0},{"imageOffset":41752,"imageIndex":0},{"imageOffset":42972,"imageIndex":0},{"imageOffset":43428,"imageIndex":0},{"imageOffset":43848,"imageIndex":0},{"imageOffset":25204,"symbol":"start","symbolLocation":2840,"imageIndex":3}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4371070976,
    "size" : 1540096,
    "uuid" : "e1ca898d-52e0-3c0c-b98e-13fcf275aa19",
    "path" : "\/Users\/USER\/Downloads\/*\/dspci",
    "name" : "dspci"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6637486080,
    "size" : 32740,
    "uuid" : "3fac373b-5c41-3c83-8f9f-c9e781e887da",
    "path" : "\/usr\/lib\/system\/libsystem_platform.dylib",
    "name" : "libsystem_platform.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6635790336,
    "size" : 532476,
    "uuid" : "a63f0ef9-59f1-3976-8a7e-2037cd50c605",
    "path" : "\/usr\/lib\/system\/libsystem_c.dylib",
    "name" : "libsystem_c.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6633578496,
    "size" : 534116,
    "uuid" : "40bedd20-da23-3b70-a9c2-a1c68a738762",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  }
],
  "sharedCache" : {
  "base" : 6632767488,
  "size" : 4728750080,
  "uuid" : "a02dcfba-3bda-3ca6-8a42-12f00a4d75d3"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=799.0M resident=0K(0%) swapped_out_or_unallocated=799.0M(100%)\nWritable regions: Total=530.5M written=305K(0%) resident=305K(0%) swapped_out=0K(0%) unallocated=530.2M(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nKernel Alloc Once                   32K        1 \nMALLOC                           522.3M       12 \nMALLOC guard page                   96K        6 \nSTACK GUARD                       56.0M        1 \nStack                             8176K        1 \n__AUTH                             749K      154 \n__AUTH_CONST                      12.4M      289 \n__DATA                            3089K      270 \n__DATA_CONST                      9889K      290 \n__DATA_DIRTY                       460K       92 \n__FONT_DATA                        2352        1 \n__LINKEDIT                       582.7M        2 \n__OBJC_RW                         2353K        1 \n__TEXT                           216.3M      299 \n__TPRO_CONST                       272K        2 \npage table in kernel               305K        1 \nshared memory                       32K        1 \n===========                     =======  ======= \nTOTAL                              1.4G     1423 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "logWritingSignature" : "8470e65a4d0c8274309fa03617f4040c161b6a53",
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "63508950b3714d3622fc77f7",
      "factorPackIds" : {
        "SIRI_MEMORY_SYNC_CONFIG" : "6526e111d0c9ce2f459b54a8"
      },
      "deploymentId" : 240000015
    },
    {
      "rolloutId" : "64c025b28b7f0e739e4fbe58",
      "factorPackIds" : {

      },
      "deploymentId" : 240000019
    }
  ],
  "experiments" : [
    {
      "treatmentId" : "c47ab4cc-c9c3-4b5d-a87c-e2433ce02597",
      "experimentId" : "6639bc6ba73d460582162323",
      "deploymentId" : 400000006
    },
    {
      "treatmentId" : "45f4e2a5-551b-4bc2-a2dc-19c244dda8f8",
      "experimentId" : "6643969b3099cf28e049862f",
      "deploymentId" : 400000007
    }
  ]
}
}

Model: Mac14,14, BootROM 11881.1.1, proc 24:16:8 processors, 64 GB, SMC 
Graphics: Apple M2 Ultra, Apple M2 Ultra, Built-In
Display: ROG PG279QM, 2560 x 1440 (QHD/WQHD - Wide Quad High Definition), Main, MirrorOff, Online
Display: BenQ LCD, 2560 x 1440 (QHD/WQHD - Wide Quad High Definition), MirrorOff, Online
Display: BenQ LCD, 2560 x 1440 (QHD/WQHD - Wide Quad High Definition), MirrorOff, Online
Memory Module: LPDDR5, Micron
AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x4388), wl0: Jul 26 2024 20:00:10 version 23.10.888.0.41.51.162 FWID 01-958c4bd4
IO80211_driverkit-1302.71 "IO80211_driverkit-1302.71" Aug  5 2024 22:09:56
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Ethernet, Ethernet, en0
Network Service: USB 5G Ethernet, Ethernet, en18
PCI Card: pci15b7,5030, NVM Express Controller, Thunderbolt@3,0,0
PCI Card: pci8086,15b6, USB eXtensible Host Controller, Thunderbolt@4,0,0
PCI Card: pci1b21,612, AHCI Controller, Thunderbolt@3,0,0
PCI Card: pci8086,15d4, USB eXtensible Host Controller, Thunderbolt@4,0,0
PCI Card: pci15b7,5041, NVM Express Controller, Thunderbolt@67,0,0
PCI Card: pci8086,15f0, USB eXtensible Host Controller, Thunderbolt@3,0,0
Serial ATA Device: ST8000VN004-3CP101, 8 TB
USB Device: USB31Bus
USB Device: USB3.2 Hub
USB Device: USB2.1 Hub
USB Device: USB31Bus
USB Device: USB3.1 Hub
USB Device: USB 5G Ethernet
USB Device: USB2.0 Hub
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: FiiO K3
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: 4-Port USB 2.0 Hub
USB Device: 4-Port USB 2.0 Hub
USB Device: USB2.0 Hub
USB Device: G815 RGB MECHANICAL GAMING KEYBOARD
USB Device: Magic Trackpad
USB Device: USB 2.0 Hub
USB Device: flirc
USB Device: CTL-472
USB Device: AmusingKeyPadK5
USB Device: Pocket Voltex
USB Device: G502 X PLUS MILLENNIUM FALCON
USB Device: Magic Keyboard with Touch ID
USB Device: CP1500AVRLCD3
USB Device: 4-Port USB 2.0 Hub
USB Device: 4-Port USB 2.0 Hub
USB Device: 4-Port USB 3.0 Hub
USB Device: 4-Port USB 3.0 Hub
USB Device: Logitech StreamCam
USB Device: 4-Port USB 3.0 Hub
USB Device: 4-Port USB 3.0 Hub
USB Device: BD-RE BU40N
USB Device: Wireless_Device
USB Device: USB31Bus
USB Device: USB 2.0 BILLBOARD
USB Device: USB31Bus
USB Device: USB31Bus
Thunderbolt Bus: Mac Studio, Apple Inc.
Thunderbolt Bus: Mac Studio, Apple Inc.
Thunderbolt Bus: Mac Studio, Apple Inc.
Thunderbolt Device: USB4.0 SSD, Intel, 1, 68.1
Thunderbolt Bus: Mac Studio, Apple Inc.
Thunderbolt Device: d2 Thunderbolt 3, LaCie, 1, 34.2
Thunderbolt Bus: Mac Studio, Apple Inc.
Thunderbolt Bus: Mac Studio, Apple Inc.
Thunderbolt Device: RocketStor 6661A, HighPoint Technologies, Inc., 1, 26.1

Address Sanitizer output:

dspci(39897,0x1f010f240) malloc: nano zone abandoned due to inability to reserve vm space.
AddressSanitizer:DEADLYSIGNAL
=================================================================
==39897==ERROR: AddressSanitizer: SEGV on unknown address 0x000100037045 (pc 0x00010507cf64 bp 0x00016b3c9cb0 sp 0x00016b3c9460 T0)
==39897==The signal is caused by a READ memory access.
    #0 0x10507cf64 in __sanitizer::internal_strlen(char const*)+0x4 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x6cf64)
    #1 0x104a3e3bc in -[DataTypeHandler loadPCIIDs] DataTypeHandler.m:98
    #2 0x104a3d608 in -[DataTypeHandler init] DataTypeHandler.m:26
    #3 0x104a57f70 in -[DSPCI application:runWithArguments:] dspci.m:86
    #4 0x104a59ef0 in -[DDCliApplication runWithDelegate:arguments:] DDCliApplication.m:93
    #5 0x104a5a6d4 in -[DDCliApplication runWithClass:] DDCliApplication.m:123
    #6 0x104a5aecc in DDCliAppRunWithClass DDCliApplication.m:165
    #7 0x104a5af60 in DDCliAppRunWithDefaultClass DDCliApplication.m:174
    #8 0x104a58bf4 in main main.m:14
    #9 0x18b64c270  (<unknown module>)

==39897==Register values:
 x[0] = 0x0000000100037045   x[1] = 0x0000000104a34480   x[2] = 0x0000000104a64da0   x[3] = 0x0000000000000010  
 x[4] = 0x0000000000000000   x[5] = 0x0000000000000000   x[6] = 0x000000016abd0000   x[7] = 0x0000000000000001  
 x[8] = 0x0000000000000000   x[9] = 0x0000000000000000  x[10] = 0x000000702096c9b4  x[11] = 0x000000002094c9b4  
x[12] = 0x000000002094c9b4  x[13] = 0x0000000000000007  x[14] = 0xf9f9f907f9f9f9f9  x[15] = 0x0000000104bd9f18  
x[16] = 0x000000010505db9c  x[17] = 0x00000001050b8130  x[18] = 0x0000000000000000  x[19] = 0x0000000100037045  
x[20] = 0x00000001efe780a0  x[21] = 0x0000000104a3e3c0  x[22] = 0x000000016b3cb448  x[23] = 0x000000016b3cb448  
x[24] = 0x000000018b646000  x[25] = 0x0000000000000000  x[26] = 0x0000000000000000  x[27] = 0x0000000000000000  
x[28] = 0x0000000000000000     fp = 0x000000016b3c9cb0     lr = 0x000000010505dbec     sp = 0x000000016b3c9460  
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x6cf64) in __sanitizer::internal_strlen(char const*)+0x4
==39897==ABORTING
Abort trap: 6

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

Successfully merging this pull request may close these issues.

1 participant