Repository navigation
Fatal error running example app #1
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed
Description
MacBook Pro, 14-inch, Nov 2023, Apple M3 Max, Tahoe 26.2
Ruby 3.3.5 (via rbenv)
go version go1.25.5 darwin/arm64 (via Homebrew)
https://charm-ruby.dev/#getting-started -> "Your First TUI"
Running this app results in a stack trace from (I assume) the Go runtime; top frame:
runtime: g 17: unexpected return pc for _cgoexp_add47dcbfd29_lipgloss_new_style called from 0x1203f4f28
stack: frame={sp:0x14000076c20, fp:0x14000076e60} stack=[0x14000076000,0x14000077000)
0x0000014000076b20: 0x000000012755f590 0x0000014000076ba8
0x0000014000076b30: 0x00000001274d2b4c <main.allocStyle+0x000000000000007c> 0x000000012753baa0
0x0000014000076b40: 0x000000012755f590 0x0000014000076b68
0x0000014000076b50: 0x00000001274d1f60 <main.getNextID+0x00000000000000e0> 0x0000000000000000
0x0000014000076b60: 0x0000000000000000 0x0000014000076ba8
0x0000014000076b70: 0x00000001274d2b2c <main.allocStyle+0x000000000000005c> 0x0000014000076ba8
0x0000014000076b80: 0x00000001274d2b00 <main.allocStyle+0x0000000000000030> 0x0000000000000001
0x0000014000076b90: 0x00000001274d1f90 <main.getNextID.deferwrap1+0x0000000000000000> 0x00000001276d4c38
0x0000014000076ba0: 0x0000014000076b90 0x0000014000076c18
0x0000014000076bb0: 0x00000001274dc320 <_cgoexp_add47dcbfd29_lipgloss_new_style+0x0000000000000050> 0x0000000000000000
0x0000014000076bc0: 0x0000000000000000 0x0000000000000000
0x0000014000076bd0: 0x0000000000000000 0x0000000000000000
0x0000014000076be0: 0x0000000000000000 0x0000000000000001
0x0000014000076bf0: 0x0000000000000001 0x00000001274d2bf0 <main.allocStyle.deferwrap1+0x0000000000000000>
0x0000014000076c00: 0x00000001276d4ea0 0x0000014000076c18
0x0000014000076c10: 0x0000014000076bf8 0x0000014000076e58
0x0000014000076c20: <0x00000001203f4f28 0x00000001276ae320
0x0000014000076c30: 0x0000000000000000 0x0000000000000000
0x0000014000076c40: 0x0000000000000000 0x0000000000000000
0x0000014000076c50: 0x0000000000000000 0x0000000000000000
0x0000014000076c60: 0x0000000000000000 0x0000000000000000
0x0000014000076c70: 0x0000000000000000 0x0000000000000000
0x0000014000076c80: 0x0000000000000000 0x0000000000000000
0x0000014000076c90: 0x0000000000000000 0x0000000000000000
0x0000014000076ca0: 0x0000000000000000 0x0000000000000000
0x0000014000076cb0: 0x0000000000000000 0x0000000000000000
0x0000014000076cc0: 0x0000000000000000 0x0000000000000000
0x0000014000076cd0: 0x0000000000000000 0x0000000000000000
0x0000014000076ce0: 0x0000000000000000 0x0000000000000000
0x0000014000076cf0: 0x0000000000000000 0x0000000000000000
0x0000014000076d00: 0x0000000000000000 0x0000000000000000
0x0000014000076d10: 0x0000000000000000 0x0000000000000000
0x0000014000076d20: 0x0000000000000000 0x0000000000000000
0x0000014000076d30: 0x0000000000000000 0x0000000000000000
0x0000014000076d40: 0x0000000000000000 0x0000000000000000
0x0000014000076d50: 0x0000000000000000 0x0000000000000000
0x0000014000076d60: 0x0000000000000000 0x0000000000000000
0x0000014000076d70: 0x0000000000000000 0x0000000000000000
0x0000014000076d80: 0x0000000000000000 0x0000000000000000
0x0000014000076d90: 0x0000000000000000 0x0000000000000000
0x0000014000076da0: 0x0000000000000000 0x0000000000000000
0x0000014000076db0: 0x0000000000000000 0x0000000000000000
0x0000014000076dc0: 0x0000000000000000 0x0000000000000000
0x0000014000076dd0: 0x0000000000000000 0x0000000000000000
0x0000014000076de0: 0x0000000000000000 0x0000000000000000
0x0000014000076df0: 0x0000000000000000 0x0000000000000000
0x0000014000076e00: 0x0000000000000000 0x0000000000000000
0x0000014000076e10: 0x0000000000000000 0x0000000000000000
0x0000014000076e20: 0x0000000000000000 0x0000000000000000
0x0000014000076e30: 0x0000000000000000 0x0000000000000000
0x0000014000076e40: 0x0000000000000000 0x0000000000000000
0x0000014000076e50: 0x00000001203f4d80 0x0000014000076f28
0x0000014000076e60: >0x00000001203f4c84 0x000000016f9f21e8
0x0000014000076e70: 0x0000000120459a28 0x0000014000076ea8
0x0000014000076e80: 0x0000000000000000 0x0000000000000000
0x0000014000076e90: 0x0100000000000000 0x0000000000000000
0x0000014000076ea0: 0x0000000000000000 0x000000012042ff00
0x0000014000076eb0: 0x0202014000076e97 0x0000014000076f28
0x0000014000076ec0: 0x00000001203f4c50 0x00000001274dc2d0 <_cgoexp_add47dcbfd29_lipgloss_new_style+0x0000000000000000>
0x0000014000076ed0: 0x0000000200000003 0x0000014000002700
0x0000014000076ee0: 0x0000014000076ec8 0x0000014000002700
0x0000014000076ef0: 0x00000001203f4fc0 0x0000014000076eb5
0x0000014000076f00: 0x000000016f9f4000 0x0000000000000000
0x0000014000076f10: 0x0000000000000000 0x0000000000000000
0x0000014000076f20: 0x0000014000076ef0 0x0000014000076f78
0x0000014000076f30: 0x0000000120462aac 0x00000001274dc2d0 <_cgoexp_add47dcbfd29_lipgloss_new_style+0x0000000000000000>
0x0000014000076f40: 0x000000016f9f21e8 0x0000000000000000
0x0000014000076f50: 0x0000000120460db4 0x0000000000000000
fatal error: unknown caller pc
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed
Activity
jeffmcfadden commentedon Dec 30, 2025
@davidrupp I ran into this as well. The Go bindings in the pre-built binaries seem to have been compiled against Go 1.23, and you (and I) are running 1.25.
I was able to get playing by re-compiling the gems locally and messing about with them that way.
I'm sure there's a good long-term solution here, but if you just want to experiment, give that a try.
davidrupp commentedon Dec 30, 2025
@jeffmcfadden Thanks for the suggestion. I also tried downgrading to go@1.23 and got what looks like the same error. I'll keep poking at it.
marcoroth commentedon Dec 30, 2025
Hey @davidrupp and @jeffmcfadden, thanks for reporting!
Sadly, this is one of the current limitations I pointed out in the blog post, but I still wanted to get these gems out there so we, as a community, can build these gems out and make them better.
From what I can tell, it only happens when you require two Charm Ruby gems that have a Go Native extension. It seems to have to do with the way Goroutines work and the order the gems are
require'd.I'm new to Go and the distribution of Go binaries. It seems to be an issue that these two gems weren't compiled on the same machine with the exact same setup, and that trips up the Goroutines and its assumptions about how things are setup.
If anyone has experience with this, I would be really happy about any feedback. Maybe it would also be better to use another approach to build Go Native Extensions, as the current approach of doing
Go library → cgo shared library → Ruby C extension → Rubyseems a bit fragile for distribution, as we can see here.The only other solution I have in mind is to create one big shared gem that has the go extension, and then all the other gems on top of it can stay in pure Ruby. With that, these native extensions wouldn't conflict with each other.
pusewicz commentedon Jan 1, 2026
Can the gems be compiled on the target (user) machine instead when installing?
mperham commentedon Jan 1, 2026
I'm getting a similar error, also on Go 1.25.5.
I wonder if Go is a poor choice for a native extension and something like Rust and Ratatui (https://ratatui.rs) would be a better choice, long-term. Ruby bindings were just published last week.
https://kerrick.blog/posts/2025/ratatui-bindings-for-ruby/
esmarkowski commentedon Jan 2, 2026
I was so looking forward to playing with these! @marcoroth Thanks for making them.
I'm getting the same error as above also and noticed there wasn't a
bundle exec rake compileas stated in the docs.I'd be happy with one big gem!
swerner commentedon Jan 4, 2026
I'm running into the same issue. I'm also new to Go, but started doing some digging with Claude.
It looks like this issue also means that if you use any other gems with Go extensions, you'd also run into a segfault, since what's happening is that we're creating multiple Go runtimes within the same process.
One option to fix this (and avoid breaking other Go-wrapper gems) could be to create a separate charm-go gem that runs Go as a subprocess. The Charm gems with native extensions would become pure Ruby and communicate with the single Go process.
I've been working with Claude on a detailed architecture doc for this if you'd be interested in seeing it @marcoroth?
esmarkowski commentedon Jan 4, 2026
@swerner lol. I went down the same path https://github.com/esmarkowski/charm-native
I can get all of the demos to work across all the gems now.
swerner commentedon Jan 4, 2026
@esmarkowski I explored this path a bit (and again, I'm really new to Go so I'm trusting AI quite a bit on this) - this approach solves the multiple charm gems with Go extension issue, wouldn't we still run into an issue if we wanted to use a different, non-Charm Go-based Gem? I know there aren't a ton out there so maybe this isn't an important concern for now...but definitely a landmine to be aware of...
swerner commentedon Jan 6, 2026
@marcoroth any thoughts? @esmarkowski do you have forks of all these charm gems pointing at
charm-nativeas well or how are you running the demos? Would love to check it out and give it a shotesmarkowski commentedon Jan 6, 2026
@swerner a non-charm, go-based gem is a really good point; and I'm not sure what you'd do in that scenario. For me, I don't think it matter much, but it does seem like a frustrating limitation.
I can put up forks later this evening.
swerner commentedon Jan 9, 2026
@esmarkowski sorry to bug you, but any chance you had time to put up those forks?
windy commentedon Jan 12, 2026
I meet the same problem(using 0.1.0 version gem):
Loading latest session: a23dfc1e
fatal error: bad sweepgen in refill
goroutine 17 gp=0x14000002700 m=1 mp=0x14000058008 [running, locked to thread]:
runtime.throw({0x10ac35ab1?, 0x0?})
/usr/local/go/src/runtime/panic.go:1067 +0x38 fp=0x14000066ca0 sp=0x14000066c70 pc=0x10ab9d528
runtime.(*mcache).refill(0x109200108, 0x0?)
/usr/local/go/src/runtime/mcache.go:157 +0x274 fp=0x14000066cf0 sp=0x14000066ca0 pc=0x10ab46324
runtime.(*mcache).nextFree(0x109200108, 0x8)
/usr/local/go/src/runtime/malloc.go:945 +0x8c fp=0x14000066d40 sp=0x14000066cf0 pc=0x10ab40e4c
runtime.mallocgc(0x20, 0x10ac87360, 0x1)
/usr/local/go/src/runtime/malloc.go:1161 +0x470 fp=0x14000066de0 sp=0x14000066d40 pc=0x10ab99220
runtime.newobject(0x0?)
/usr/local/go/src/runtime/malloc.go:1386 +0x2c fp=0x14000066e10 sp=0x14000066de0 pc=0x10ab4112c
main.tea_new_program()
/home/runner/work/bubbletea-ruby/bubbletea-ruby/go/bubbletea.go:52 +0x24 fp=0x14000066e50 sp=0x14000066e10 pc=0x10ac2a6a4
_cgoexp_63929b4de9f7_tea_new_program(0x16b5a1aa8)
_cgo_gotypes.go:117 +0x20 fp=0x14000066e60 sp=0x14000066e50 pc=0x10ac2ec30
runtime: g 17: unexpected return pc for _cgoexp_63929b4de9f7_tea_new_program called from 0x109c220b8
stack: frame={sp:0x14000066e50, fp:0x14000066e60} stack=[0x14000066000,0x14000067000)
palladius commentedon Jan 12, 2026
Same bug here.
ruby ver: 3.4.5
palladius commentedon Jan 12, 2026
@marcoroth I quickly scanned your article (its long!) for Error, or binding, and didnt find anything.
May I suggest, for clarity, to add a mono line on the limitation on the first failing demo?
https://charm-ruby.dev/?utm_source=shortrubynews&utm_medium=newsletter&utm_campaign=short-ruby-newsletter-edition-163&_bhlid=046b257a6d678c8f3c5b7b934e6ccc5fc9c189e7#getting-started
-> ## Your First TUI
Maybe something "Warning, might not work on your ARM M1 Mac" , or similar.
pejaustin commentedon Jan 14, 2026
@esmarkowski Appreciate you putting together a workaround, but it's not working for me just adding to my gemfile. Is there something I'm missing about how to do this? Do I have to install the source locally and build the go ext?
esmarkowski commentedon Jan 14, 2026
sorry about that @swerner and @pejaustin. I created forks of all the libraries and pushed:
https://github.com/esmarkowski/bubbletea-ruby/tree/no-path-gemfiles
https://github.com/esmarkowski/bubbletea-ruby/tree/no-path-gemfiles
https://github.com/esmarkowski/lipgloss-ruby/tree/no-path-gemfiles
https://github.com/esmarkowski/huh-ruby/tree/no-path-gemfiles
https://github.com/esmarkowski/glamour-ruby/tree/no-path-gemfiles
https://github.com/esmarkowski/bubbles-ruby/tree/no-path-gemfiles
https://github.com/esmarkowski/gum-ruby/tree/no-path-gemfiles
https://github.com/esmarkowski/bubblezone-ruby/tree/no-path-gemfiles
https://github.com/esmarkowski/harmonica-ruby/tree/no-path-gemfiles
https://github.com/esmarkowski/ntcharts-ruby/tree/no-path-gemfiles
This is essentially what happens in each repo:
bubbletea-ruby/lib/bubbletea.rb
I've updated the charm-native to include rake tasks to build everything locally for you (uses
bundle configto set local overrides)https://github.com/esmarkowski/charm-native
marcoroth commentedon Jan 15, 2026
Hey friends, sorry for the lack of updates here, it's been a few hectic weeks in the new year!
I have been working on getting the
charmgem name on RubyGems.org for a very similar reason, even before I released the gems publicly.I think there's an argument to make to have all the native extensions to be bundled into a single gem that provides the native extension for all other gems, so that all other gems can stay pure Ruby. Maybe it also makes sense that
charmis the single "user-facing" gem that people have to install, and have it depend on the other gems.Maybe it makes sense to move these repos into the
charm-rubyorg here on GitHub, so it's easier to manage these repos and also easier to follow. But also so we can build on the work @esmarkowski has done (thank you!) and move that over too.palladius commentedon Jan 15, 2026
Tranquillo Marco.
If someone gives me a README I can follow to install them EASY on my machine, wether Mac or Linux, I'm happy to give it a try and to update the docs! But I need something to start from.
Apologies esmarkowski@ but I find your README hard to follow: https://github.com/esmarkowski/charm-native (I have zero experience transpiling gems, only transpiling docker!)
glmsilva commentedon Feb 14, 2026
Hi people. How can one help you guys with this?
I tried creating some simple application to test the gem and noticed that when including bubbletea and lipgloss gems together, I get this same error. Probably this is the reason, both gems are creating go runtimes and causing a segfault. But it did not happened when I was using the bubbletea gem alone.
I don't know anything about go yet, but I would love to help with something, I'm trying to build some tui apps with bubbletea and I think this gem should be great to start with.
marcoroth commentedon Feb 17, 2026
Hey friends, looks like @khasinski was able to crack the puzzle and that we don't need a single gem that bundles all the native extensions! We just released his pull request (#4) as part of
v0.1.1that seems to fix this issue!We are going through the remaining gems to apply the same fix and then this should hopefully work out of the box as expected!
Please let us know if you still see any crashes, thank you!
marcoroth commentedon Feb 17, 2026
Going to close this as we updated all gems now. Please feel free to re-open if you still see unexpected crashes, thank you! 🙏🏼