Skip to content

Segfault while cloning if built with Python 3.10 on macOS #279

@lf-

Description

@lf-

Thanks to sggutier, I've got the ability to edit Python files worked out. I'm investigating why the nixpkgs build of Sapling for macOS is broken, and I think I've found a bug.

Downstream report: NixOS/nixpkgs#202754

When I clone a repository with the oss build of Sapling, it does a segmentation fault. I've traced it down to

for name, module in extensions.extensions(ui):
hook = getattr(module, "reposetup", None)
if hook:
hook(ui, repo)

which I've added some printf debugging to:

    for name, module in extensions.extensions(ui):
        print('doing', repr(name), repr(module))
        hook = getattr(module, "reposetup", None)
        if hook:
            hook(ui, repo)

With that context, here's it crashing in a debugger:

Running it in lldb
$ nix-shell -E 'with import (builtins.fetchTarball "https://github.com/nixos/nixpkgs
/archive/872fceeed60ae6b7766cc0a4cd5bf5901b9098ec.tar.gz") {}; mkShell { packages = [ yarn libiconv std
env openssl curl pkg-config darwin.apple_sdk.frameworks.CoreFoundation darwin.apple_sdk.frameworks.Secu
rity darwin.apple_sdk.frameworks.CoreServices python3 ]; }'

[nix-shell:~/dev/sapling2/eden/scm]$ make oss
[nix-shell:~/dev/sapling2/eden/scm]$ rm -rf polkadots && CHGDISABLE=1 lldb -- ./sl clone https://github.com/lf-/polkadots
(lldb) target create "./sl"
Current executable set to '/Users/jade/dev/sapling2/eden/scm/sl' (arm64).
(lldb) settings set -- target.run-args  "clone" "https://github.com/lf-/polkadots"
(lldb) r
Process 36765 launched: '/Users/jade/dev/sapling2/eden/scm/sl' (arm64)
doing 'tweakdefaults' <module 'edenscm.ext.tweakdefaults' from '/Users/jade/dev/sapling2/eden/scm/edens
cm/ext/tweakdefaults.py'>
doing 'absorb' <module 'edenscm.ext.absorb' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/absorb/
__init__.py'>
doing 'amend' <module 'edenscm.ext.amend' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/amend/__i
nit__.py'>
doing 'automv' <module 'edenscm.ext.automv' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/automv.
py'>
doing 'blackbox' <module 'edenscm.ext.blackbox' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/bla
ckbox.py'>
doing 'chistedit' <module 'edenscm.ext.chistedit' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/c
histedit.py'>
doing 'conflictinfo' <module 'edenscm.ext.conflictinfo' from '/Users/jade/dev/sapling2/eden/scm/edenscm
/ext/conflictinfo.py'>
doing 'copytrace' <module 'edenscm.ext.copytrace' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/c
opytrace.py'>
doing 'debugnetwork' <module 'edenscm.ext.debugnetwork' from '/Users/jade/dev/sapling2/eden/scm/edenscm
/ext/debugnetwork.py'>
doing 'dialect' <module 'edenscm.ext.dialect' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/diale
ct.py'>
doing 'dirsync' <module 'edenscm.ext.dirsync' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/dirsy
nc.py'>
doing 'extorder' <module 'edenscm.ext.extorder' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/ext
order.py'>
doing 'fbhistedit' <module 'edenscm.ext.fbhistedit' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext
/fbhistedit.py'>
doing 'sparse' <module 'edenscm.ext.sparse' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/sparse.
py'>
doing 'fsmonitor' <module 'edenscm.ext.fsmonitor' from '/Users/jade/dev/sapling2/eden/scm/edenscm/ext/f
smonitor/__init__.py'>
watchman sockpath is set as /opt/facebook/watchman/var/run/watchman/jade-state/sock
Process 36765 stopped
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, addr
ess=0x2f7665642f656481)
    frame #0: 0x00000001039cefc8 libpython3.10.dylib`subtype_dealloc + 876
libpython3.10.dylib`subtype_dealloc:
->  0x1039cefc8 <+876>: ldr    x8, [x8, #0x20]
    0x1039cefcc <+880>: add    x8, x24, x8
    0x1039cefd0 <+884>: add    x26, x8, #0x10
    0x1039cefd4 <+888>: b      0x1039cefe4               ; <+904>
Target 0: (sl) stopped.
(lldb) bt
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, addr
ess=0x2f7665642f656481)
  * frame #0: 0x00000001039cefc8 libpython3.10.dylib`subtype_dealloc + 876
    frame #1: 0x000000010398ebc4 libpython3.10.dylib`frame_dealloc + 168
    frame #2: 0x0000000103a4424c libpython3.10.dylib`_PyEval_Vector + 208
    frame #3: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #4: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #5: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #6: 0x0000000103972564 libpython3.10.dylib`_PyObject_FastCallDictTstate + 312
    frame #7: 0x00000001039730b0 libpython3.10.dylib`_PyObject_Call_Prepend + 148
    frame #8: 0x00000001039da90c libpython3.10.dylib`slot_tp_init + 216
    frame #9: 0x00000001039cfc68 libpython3.10.dylib`type_call + 352
    frame #10: 0x0000000103972774 libpython3.10.dylib`_PyObject_MakeTpCall + 360
    frame #11: 0x0000000103a4cbd0 libpython3.10.dylib`call_function + 524
    frame #12: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #13: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #14: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #15: 0x0000000103a4a29c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24464
    frame #16: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #17: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #18: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #19: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #20: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #21: 0x0000000103a4a37c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24688
    frame #22: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #23: 0x0000000103972b7c libpython3.10.dylib`PyVectorcall_Call + 160
    frame #24: 0x00000001001da35c sl`pytracing::wrapfunc::__call__::hb328591bde70cd83 + 1088
    frame #25: 0x00000001002000dc sl`std::panicking::try::h088e29f4495f689b + 124
    frame #26: 0x00000001001dabc0 sl`pytracing::wrapfunc::create_instance::TYPE_OBJECT::wrap_call::h42f
6d44cc211d035 + 56
    frame #27: 0x0000000103972774 libpython3.10.dylib`_PyObject_MakeTpCall + 360
    frame #28: 0x0000000103a4cbd0 libpython3.10.dylib`call_function + 524
    frame #29: 0x0000000103a4a37c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24688
    frame #30: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #31: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #32: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #33: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #34: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #35: 0x0000000103a4a29c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24464
    frame #36: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #37: 0x0000000103972b7c libpython3.10.dylib`PyVectorcall_Call + 160
    frame #38: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #39: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #40: 0x0000000103972b7c libpython3.10.dylib`PyVectorcall_Call + 160
    frame #41: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #42: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #43: 0x0000000103972b7c libpython3.10.dylib`PyVectorcall_Call + 160
    frame #44: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #45: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #46: 0x0000000103ad7d78 libpython3.10.dylib`partial_vectorcall + 264
    frame #47: 0x0000000103972b7c libpython3.10.dylib`PyVectorcall_Call + 160
    frame #48: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #49: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #50: 0x0000000103972b7c libpython3.10.dylib`PyVectorcall_Call + 160
    frame #51: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #52: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #53: 0x0000000103972b7c libpython3.10.dylib`PyVectorcall_Call + 160
    frame #54: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #55: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #56: 0x0000000103ad7d78 libpython3.10.dylib`partial_vectorcall + 264
    frame #57: 0x0000000103972b7c libpython3.10.dylib`PyVectorcall_Call + 160
    frame #58: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #59: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #60: 0x0000000103972b7c libpython3.10.dylib`PyVectorcall_Call + 160
    frame #61: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #62: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #63: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #64: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #65: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #66: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #67: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #68: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #69: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #70: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #71: 0x0000000103ad7f04 libpython3.10.dylib`partial_vectorcall + 660
    frame #72: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #73: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #74: 0x0000000103ad7f04 libpython3.10.dylib`partial_vectorcall + 660
    frame #75: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #76: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #77: 0x0000000103ad7f04 libpython3.10.dylib`partial_vectorcall + 660
    frame #78: 0x0000000103a4a58c libpython3.10.dylib`_PyEval_EvalFrameDefault + 25216
    frame #79: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #80: 0x0000000103ad7d78 libpython3.10.dylib`partial_vectorcall + 264
    frame #81: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #82: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #83: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #84: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #85: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #86: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #87: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #88: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #89: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #90: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #91: 0x0000000103a4a29c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24464
    frame #92: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #93: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #94: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #95: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #96: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #97: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #98: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #99: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #100: 0x0000000103a4a30c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24576
    frame #101: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #102: 0x0000000103a4cb70 libpython3.10.dylib`call_function + 428
    frame #103: 0x0000000103a4a29c libpython3.10.dylib`_PyEval_EvalFrameDefault + 24464
    frame #104: 0x0000000103a44210 libpython3.10.dylib`_PyEval_Vector + 148
    frame #105: 0x00000001000365b0 sl`cpython::objects::module::PyModule::call::h90a1e055d211397c + 200
    frame #106: 0x00000001000227cc sl`hgcommands::hgpython::HgPython::run_hg::h707bfb8605d4e3ea + 1032
    frame #107: 0x000000010017bf94 sl`hgcommands::run::dispatch_command::h5f062792a193530b + 3552
    frame #108: 0x0000000100179f7c sl`hgcommands::run::run_command::h276de7840f763b97 + 5512
    frame #109: 0x000000010000733c sl`hgmain::main::h7545a2090cef6562 + 628
    frame #110: 0x0000000100004738 sl`std::sys_common::backtrace::__rust_begin_short_backtrace::h1ff369
d9f3dd50c1 + 12
    frame #111: 0x0000000100004818 sl`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h9b346f7b160f2
825 + 16
    frame #112: 0x0000000101751c80 sl`std::rt::lang_start_internal::h94fa211da9d06d56 [inlined] core::o
ps::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_onc
e::h0c60ab225fafdaa1 at function.rs:283:13 [opt]
    frame #113: 0x0000000101751c78 sl`std::rt::lang_start_internal::h94fa211da9d06d56 [inlined] std::pa
nicking::try::do_call::he83c34dec7ecf156 at panicking.rs:492:40 [opt]
    frame #114: 0x0000000101751c78 sl`std::rt::lang_start_internal::h94fa211da9d06d56 [inlined] std::pa
nicking::try::hf8a127683312d6e6 at panicking.rs:456:19 [opt]
    frame #115: 0x0000000101751c78 sl`std::rt::lang_start_internal::h94fa211da9d06d56 [inlined] std::pa
nic::catch_unwind::h6bfb2185c735f4ae at panic.rs:137:14 [opt]
    frame #116: 0x0000000101751c78 sl`std::rt::lang_start_internal::h94fa211da9d06d56 [inlined] std::rt
::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::he1235e45f833117a at rt.rs:148:48 [opt]
    frame #117: 0x0000000101751c78 sl`std::rt::lang_start_internal::h94fa211da9d06d56 [inlined] std::pa
nicking::try::do_call::h600fcfa83f96c092 at panicking.rs:492:40 [opt]
    frame #118: 0x0000000101751c78 sl`std::rt::lang_start_internal::h94fa211da9d06d56 [inlined] std::pa
nicking::try::h3ab439188ed13993 at panicking.rs:456:19 [opt]
    frame #119: 0x0000000101751c78 sl`std::rt::lang_start_internal::h94fa211da9d06d56 [inlined] std::pa
nic::catch_unwind::hb86c613836afcf80 at panic.rs:137:14 [opt]
    frame #120: 0x0000000101751c78 sl`std::rt::lang_start_internal::h94fa211da9d06d56 at rt.rs:148:20 [
opt]
    frame #121: 0x0000000100007400 sl`main + 52
    frame #122: 0x0000000102edd08c dyld`start + 520

Notes

  • I found that somehow the tooling for building Sapling with the oss build is finding the Homebrew Python 3.8 as installed by installing the binary distribution and only half using the python3 provided by the Nix shell. I had to delete that to get Sapling to cleanly build
  • The nix-shell command above will get you the exact package versions I used, you just need Nix installed :)
  • I am currently rebuilding Python with debug symbols to see if I can get better data (such as the python stack) in that backtrace

System details: macOS 12.6.1 on aarch64; packages from Nix.

Metadata

Metadata

Assignees

Labels

fix readyA fix was created. It's pending review or push.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions