TritonDataCenter / pkgsrc

NetBSD/pkgsrc fork for our binary package repositories
https://pkgsrc.smartos.org/
132 stars 51 forks source link

Segmentation fault on macos when installing a new package #293

Closed gaultier closed 3 years ago

gaultier commented 3 years ago
sudo pkgin -y install mysql-client
reading local summary...
processing local summary...
calculating dependencies...done.
zsh: segmentation fault  sudo pkgin -y install mysql-client

sudo su

lldb pkgin -y install mysql-client
warning: ignoring unknown option: -y
(lldb) target create "pkgin"
Current executable set to 'pkgin' (x86_64).
(lldb) settings set -- target.run-args  "install" "mysql-client"
(lldb) r
Process 67927 launched: '/opt/pkg/bin/pkgin' (x86_64)
calculating dependencies...done.
Process 67927 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff6bb96e52 libsystem_platform.dylib`_platform_strlen + 18
libsystem_platform.dylib`_platform_strlen:
->  0x7fff6bb96e52 <+18>: pcmpeqb (%rdi), %xmm0
    0x7fff6bb96e56 <+22>: pmovmskb %xmm0, %esi
    0x7fff6bb96e5a <+26>: andq   $0xf, %rcx
    0x7fff6bb96e5e <+30>: orq    $-0x1, %rax
Target 0: (pkgin) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00007fff6bb96e52 libsystem_platform.dylib`_platform_strlen + 18
    frame #1: 0x00007fff6ba46cd8 libsystem_c.dylib`strdup + 18
    frame #2: 0x000000010000ba65 pkgin`xstrdup + 9
    frame #3: 0x000000010000574c pkgin`order_install + 191
    frame #4: 0x0000000100002248 pkgin`pkgin_install + 1320
    frame #5: 0x0000000100005120 pkgin`main + 1060
    frame #6: 0x00007fff6b9a0cc9 libdyld.dylib`start + 1
    frame #7: 0x00007fff6b9a0cc9 libdyld.dylib`start + 1

Indeed when using dtrace we see that strdup and hence strlen are called on a NULL address:

sudo dtrace -n 'pid$target::_platform_strlen:entry { printf("%p", arg0) }' -c 'pkgin install mysql-client'
... [elided]
 6   5382           _platform_strlen:entry 0

pkgin upgrade also segfaults in the same way with a similar backtrace. I have installed it following the official commands (minus the gpg check).

Thanks for the tool, it is otherwise great.

jperkin commented 3 years ago

Hmm, this may be NetBSDfr/pkgin#94. If you run pkg_add -U pkgin and then try again does it still fail?

gaultier commented 3 years ago

Yes, it seems to work now after running this command. Thanks.