tree-sitter: *** stack smashing detected ***: terminated Fatal error 6: Aborted
Problem
Hi, I updated tree-sitter on ArchLinux from 0.22.2-1 -> 0.22.4-1. After the upgrade, emacs has started to crash whenever I load any tsx file with the following backtrace:
*** stack smashing detected ***: terminated
Fatal error 6: Aborted
Backtrace:
emacs(+0x18a436)[0x5de6a212b436]
emacs(+0x24df3)[0x5de6a1fc5df3]
emacs(+0x25d01)[0x5de6a1fc6d01]
emacs(+0x2cf70d)[0x5de6a227070d]
/usr/lib/libc.so.6(+0x3c770)[0x727ab68fd770]
/usr/lib/libc.so.6(+0x8d32c)[0x727ab694e32c]
/usr/lib/libc.so.6(gsignal+0x18)[0x727ab68fd6c8]
/usr/lib/libc.so.6(abort+0xd7)[0x727ab68e54b8]
/usr/lib/libc.so.6(+0x25395)[0x727ab68e6395]
/usr/lib/libc.so.6(+0x11473b)[0x727ab69d573b]
/usr/lib/libc.so.6(+0x115a56)[0x727ab69d6a56]
emacs(+0x299883)[0x5de6a223a883]
/usr/lib/emacs/29.3/native-lisp/29.3-561b282f/treesit-37439c61-97df641d.eln(F747265657369742d666f6e742d6c6f636b2d666f6e746966792d726567696f6e_treesit_font_lock_fontify_region_0+0x1f2)[0x727a8eb6e832]
emacs(+0x21052e)[0x5de6a21b152e]
/usr/bin/../lib/emacs/29.3/native-lisp/29.3-561b282f/preloaded/font-lock-895216f6-1f3b244f.eln(F666f6e742d6c6f636b2d666f6e746966792d73796e746163746963616c6c792d726567696f6e_font_lock_fontify_syntactically_region_0+0x62)[0x727ab1e38f42]
emacs(+0x21052e)[0x5de6a21b152e]
/usr/bin/../lib/emacs/29.3/native-lisp/29.3-561b282f/preloaded/font-lock-895216f6-1f3b244f.eln(F666f6e742d6c6f636b2d64656661756c742d666f6e746966792d726567696f6e_font_lock_default_fontify_region_0+0x4af)[0x727ab1e36bef]
emacs(+0x21052e)[0x5de6a21b152e]
/usr/bin/../lib/emacs/29.3/native-lisp/29.3-561b282f/preloaded/font-lock-895216f6-1f3b244f.eln(F666f6e742d6c6f636b2d666f6e746966792d726567696f6e_font_lock_fontify_region_0+0x93)[0x727ab1e35873]
emacs(+0x25789e)[0x5de6a21f889e]
emacs(+0x21052e)[0x5de6a21b152e]
emacs(+0x211041)[0x5de6a21b2041]
emacs(+0x20ccac)[0x5de6a21adcac]
/usr/bin/../lib/emacs/29.3/native-lisp/29.3-561b282f/preloaded/jit-lock-8a988e43-a9956d8b.eln(F6a69742d6c6f636b2d2d72756e2d66756e6374696f6e73_jit_lock__run_functions_0+0xd8)[0x727ab1acac88]
emacs(+0x21052e)[0x5de6a21b152e]
/usr/bin/../lib/emacs/29.3/native-lisp/29.3-561b282f/preloaded/jit-lock-8a988e43-a9956d8b.eln(F6a69742d6c6f636b2d666f6e746966792d6e6f77_jit_lock_fontify_now_0+0x80a)[0x727ab1acb59a]
emacs(+0x21052e)[0x5de6a21b152e]
/usr/bin/../lib/emacs/29.3/native-lisp/29.3-561b282f/preloaded/jit-lock-8a988e43-a9956d8b.eln(F6a69742d6c6f636b2d66756e6374696f6e_jit_lock_function_0+0x26f)[0x727ab1aca98f]
emacs(+0x21052e)[0x5de6a21b152e]
emacs(+0x2d2b21)[0x5de6a2273b21]
emacs(+0x5706b)[0x5de6a1ff806b]
emacs(+0x5af00)[0x5de6a1ffbf00]
emacs(+0x5c086)[0x5de6a1ffd086]
emacs(+0x5e036)[0x5de6a1fff036]
emacs(+0x5c2b6)[0x5de6a1ffd2b6]
emacs(+0x7ae89)[0x5de6a201be89]
emacs(+0x82d92)[0x5de6a2023d92]
emacs(+0x73863)[0x5de6a2014863]
emacs(+0x20b43c)[0x5de6a21ac43c]
emacs(+0x737b8)[0x5de6a20147b8]
emacs(+0x774b2)[0x5de6a20184b2]
...
zsh: IOT instruction (core dumped) emacs
I downgraded back to 0.22.2-1 and do not face any issues.
Steps to reproduce
- pacman -Syyu <- updates tree-sitter to 0.22.4-1
- Start emacs
- Open any
tsx
file.
Expected behavior
Emacs should not crash and I can open tsx files.
Tree-sitter version (tree-sitter --version)
tree-sitter 0.20.8 (d4c1bf7ce78051b7f4a381d1508d68928512ed5f)
Operating system/version
ArchLinux
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Reactions: 17
- Comments: 44 (22 by maintainers)
Links to this issue
Commits related to this issue
- feat(treesit): 添加 treesit 支持 1. GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) 和 treesit 0.22.5-1 存在兼容性 bug 导致 Emacs 崩溃。 https://github.com/tree-sitter/tre... — committed to awerdx520/emacs.d by awerdx520 2 months ago
- *: tree-sitter had an ABI bump without bumping its shared libraries Bump ABI depends and bump PKGREVISIONs of users. https://github.com/tree-sitter/tree-sitter/issues/3296 — committed to NetBSD/pkgsrc by deleted user 2 months ago
For anyone wanting to downgrade on Arch, I’ve been able to get Emacs non-crashing again with
sudo pacman -U file:///var/cache/pacman/pkg/tree-sitter-0.22.2-1-x86_64.pkg.tar.zst
[1].[1] https://wiki.archlinux.org/title/downgrading_packages
If you don’t have the old version of tree-sitter locally, you can download it from the Arch Linux archive at https://archive.archlinux.org/packages/t/tree-sitter/tree-sitter-0.22.2-1-x86_64.pkg.tar.zst
Downgrading to this version fixes it for me, for now.
Breaking ABI compatibility is not an issue at all, especially pre-1.0.
It would make things easier for consumers if the library’s soname was bumped when ABI changed though. Having a different soname allows for the incompatible versions to be installed side by side, and is a signal that consumers need to be rebuilt when it changes.
That’s correct, I’ve written about this in the past for those who want the gory details. @maxbrunsfeld for us, I think we have to commit to not using the semver version in our library names, and to follow libtool-compatible rules for selecting a SONAME instead. Even though our semver version is pre-1.0, I think we need to be diligent about bumping the SONAME version whenever we introduce a breaking change to the ABI. SONAMEs are different, and don’t have the same “everything goes before 1.0” rule that semver has. And it is often the case that a libary SONAME is not consistent with the package version number, regardless of whether the project uses semver.
@adonig you can downgrade to the previous version of libtree-sitter via
sudo dnf install libtree-sitter-0.22.2-1.fc40
and addexcludepkgs=libtree-sitter
to/etc/dnf/dnf.conf
until the issue is resolved. Works for me on Fedora 40 with Emacs 29.3.I really think that in order to provide a reliable end-user experience, and prevent issue like this, Emacs should just statically link a particular version of Tree-sitter.
If some Linux distros mandates that all libraries, no matter how small, must be distributed as dynamic libraries (which is just… staggeringly impractical IMO), then the Emacs package should specify a particular version of the Tree-sitter package to use - not a version range.
I agree with this. Ideally, we should set up tooling to automatically bump the soname on breaking ABI changes. But if any Emacs package maintainer is seeing this issue - we do not yet have this tooling - this library is maintained by a small team, and may not have perfect ABI stability! Consider taking a more conservative approach to dependency versioning, so that end users don’t have to deal with situations like this!
It sounds like in the future, we should bump the library’s minor version when changing any structs in
api.h
, because with our current strategy, the soname is based on the minor version.The Tree-sitter C library’s ABI has indeed changed (due to the
TSQueryCursor
struct field addition). I think that the Arch Emacs package should probably pin a specific version of the Tree-sitter package. I really don’t want Emacs users to be broken by changes to Tree-sitter. Does anyone know the maintainers of the Arch packages?In this repo, we try to not make breaking changes unnecessarily, but the library is pre 1.0, in its Semver versioning, and even once it goes 1.0, it’s going to be easier to maintain API stability than full-on ABI stability.
Dynamic libraries are fine, distros just need to ensure that the package that has tree-sitter as a shared lib dep uses the exact same version that the distro provides, but going forward we will try to be more mindful about abi breakage
Go ask the distros.
Arch users may be interested to know that rebuilding emacs 29.3-2 with tree-sitter 0.22.5-1 did not fix the issue for me.
Downstream emacs issue: https://gitlab.archlinux.org/archlinux/packaging/packages/emacs/-/issues/2
I suspect we’ve hit the same thing in Gentoo as https://bugs.gentoo.org/930039 - it looks like 0.22.2 vs 0.22.4 breaks ABI?
EDIT: quoting some details from the Gentoo bug…
libabigail’s abidiff output is:
I’ve filed a bug upstream with libabigail after discussion on IRC wrt why it didn’t flag it as a breaking change (https://sourceware.org/bugzilla/show_bug.cgi?id=31642).
Truncated backtrace (full at https://bugs.gentoo.org/930039#c2) from our
pkgcheck
tool which uses tree-sitter-bash:Valgrind output: