At Wed, 16 Mar 2022 00:01:34 -0700, "Greg A. Woods" <woods%planix.ca@localhost> wrote: Subject: pkg_delete crashing due to invalid glob(3) result on macOS 12.1 > > So, this has been happening on my new macOS system running macOS 12.1 (Monterey). > > It would seem as if the system-supplied glob(3) is returning an invalid > result where the gl_pathc field is apparently correct, but gl_pathv is > still NULL. > > Has anyone else seen this or anything similar (i.e. esp. on macOS)? So, my test program works perfectly: https://github.com/robohack/experiments/blob/master/tglob.c I think I found the problem though. For my test program the call to glob() is converted to glob$INODE64(), while in pkg_delete, it's still just calling plain glob() (and apparently libSystem's plain glob() is broken!) $ lldb tglob Breakpoint 1: no locations (pending). Breakpoint set in dummy target, will get copied into future targets. error: invalid target, create a target using the 'target create' command (lldb) target create "tglob" Current executable set to '/Users/woods/work/experiments/tglob' (x86_64). (lldb) breakpoint set -b glob Breakpoint 2: where = libsystem_c.dylib`glob, address = 0x00007ff8002611a0 (lldb) breakpoint set -b glob$INODE64 Breakpoint 3: where = libsystem_c.dylib`glob$INODE64, address = 0x00007ff800216a70 (lldb) run Process 41938 launched: '/Users/woods/work/experiments/tglob' (x86_64) tglob(41938,0x100090600) malloc: adding guard pages for large allocator blocks tglob(41938,0x100090600) malloc: enabling scribbling to detect mods to free blocks tglob(41938,0x100090600) malloc: enabling abort() on bad malloc or free tglob(41938,0x100090600) malloc: checks heap after operation #1 and each 1 operations tglob(41938,0x100090600) malloc: will abort on heap corruption Process 41938 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1 frame #0: 0x00007ff809233a70 libsystem_c.dylib`glob$INODE64 libsystem_c.dylib`glob$INODE64: -> 0x7ff809233a70 <+0>: pushq %rbp 0x7ff809233a71 <+1>: movq %rsp, %rbp 0x7ff809233a74 <+4>: andl $0x7ffffeff, %esi ; imm = 0x7FFFFEFF 0x7ff809233a7a <+10>: movl %esi, 0x18(%rcx) Target 0: (tglob) stopped. (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1 * frame #0: 0x00007ff809233a70 libsystem_c.dylib`glob$INODE64 frame #1: 0x00000001000037c7 tglob`test_in_symlink_to_dir at tglob.c:75:8 [opt] frame #2: 0x000000010000365b tglob`main at tglob.c:185:12 [opt] frame #3: 0x00000001000154fe dyld`start + 462 (lldb) My test program is compiled without any special -D_*_SOURCE flags, and with '-std=c99', so somehow the default compilation environment works correctly; but pkgsrc, and/or the pkg_install build itself, is doing something to upset this. -- Greg A. Woods <gwoods%acm.org@localhost> Kelowna, BC +1 250 762-7675 RoboHack <woods%robohack.ca@localhost> Planix, Inc. <woods%planix.com@localhost> Avoncote Farms <woods%avoncote.ca@localhost>
Attachment:
pgpjrgFdAFeck.pgp
Description: OpenPGP Digital Signature