Skip to content

Fatal error running example app #1

Closed

Description

@davidrupp

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

Activity

  1. jeffmcfadden commented on Dec 30, 2025

    @jeffmcfadden

    @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.

  2. davidrupp commented on Dec 30, 2025

    @davidrupp
    Author

    @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.

  3. marcoroth commented on Dec 30, 2025

    @marcoroth
    Owner

    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 → Ruby seems 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.

  4. pusewicz commented on Jan 1, 2026

    @pusewicz

    Can the gems be compiled on the target (user) machine instead when installing?

  5. mperham commented on Jan 1, 2026

    @mperham

    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/

  6. esmarkowski commented on Jan 2, 2026

    @esmarkowski

    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 compile as stated in the docs.

    I'd be happy with one big gem!

  7. swerner commented on Jan 4, 2026

    @swerner

    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?

  8. esmarkowski commented on Jan 4, 2026

    @esmarkowski

    @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.

    Image

  9. swerner commented on Jan 4, 2026

    @swerner

    @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...

  10. swerner commented on Jan 6, 2026

    @swerner

    @marcoroth any thoughts? @esmarkowski do you have forks of all these charm gems pointing at charm-native as well or how are you running the demos? Would love to check it out and give it a shot

  11. esmarkowski commented on Jan 6, 2026

    @esmarkowski

    @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.

  12. swerner commented on Jan 9, 2026

    @swerner

    @esmarkowski sorry to bug you, but any chance you had time to put up those forks?

  13. windy commented on Jan 12, 2026

    @windy

    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)

  14. palladius commented on Jan 12, 2026

    @palladius

    Same bug here.

    $ ruby ciao_marco.rb  1>t 2>&1 
    runtime: g 17: unexpected return pc for _cgoexp_add47dcbfd29_lipgloss_new_style called from 0x11c3dcf28
    stack: frame={sp:0x14000084c20, fp:0x14000084e60} stack=[0x14000084000,0x14000085000)
    0x0000014000084b20:  0x00000001434bb590  0x0000014000084ba8 
    0x0000014000084b30:  0x000000014342eb4c <main.allocStyle+0x000000000000007c>  0x0000000143497aa0 
    0x0000014000084b40:  0x00000001434bb590  0x0000014000084b68 
    0x0000014000084b50:  0x000000014342df60 <main.getNextID+0x00000000000000e0>  0x0000000000000000 
    0x0000014000084b60:  0x0000000000000000  0x0000014000084ba8 
    0x0000014000084b70:  0x000000014342eb2c <main.allocStyle+0x000000000000005c>  0x0000014000084ba8 
    0x0000014000084b80:  0x000000014342eb00 <main.allocStyle+0x0000000000000030>  0x0000000000000001 
    0x0000014000084b90:  0x000000014342df90 <main.getNextID.deferwrap1+0x0000000000000000>  0x0000000143630c38 
    0x0000014000084ba0:  0x0000014000084b90  0x0000014000084c18 
    0x0000014000084bb0:  0x0000000143438320 <_cgoexp_add47dcbfd29_lipgloss_new_style+0x0000000000000050>  0x0000000000000000 
    0x0000014000084bc0:  0x0000000000000000  0x0000000000000000 
    0x0000014000084bd0:  0x0000000000000000  0x0000000000000000 
    0x0000014000084be0:  0x0000000000000000  0x0000000000000001 
    0x0000014000084bf0:  0x0000000000000001  0x000000014342ebf0 <main.allocStyle.deferwrap1+0x0000000000000000> 
    0x0000014000084c00:  0x0000000143630ea0  0x0000014000084c18 
    0x0000014000084c10:  0x0000014000084bf8  0x0000014000084e58 
    0x0000014000084c20: <0x000000011c3dcf28  0x000000014360a320 
    0x0000014000084c30:  0x0000000000000000  0x0000000000000000 
    0x0000014000084c40:  0x0000000000000000  0x0000000000000000 
    0x0000014000084c50:  0x0000000000000000  0x0000000000000000 
    0x0000014000084c60:  0x0000000000000000  0x0000000000000000 
    0x0000014000084c70:  0x0000000000000000  0x0000000000000000 
    [...]
    Abort trap: 6
    
    $ uname -a
    Darwin ricc-mac.roam.internal 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov  5 21:30:44 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6041 arm64
    

    ruby ver: 3.4.5

  15. palladius commented on Jan 12, 2026

    @palladius

    @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.

  16. pejaustin commented on Jan 14, 2026

    @pejaustin

    @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?

  17. esmarkowski commented on Jan 14, 2026

    @esmarkowski
  18. marcoroth commented on Jan 15, 2026

    @marcoroth
    Owner

    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 charm gem 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 charm is 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-ruby org 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.

  19. palladius commented on Jan 15, 2026

    @palladius

    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!)

  20. glmsilva commented on Feb 14, 2026

    @glmsilva

    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.

  21. marcoroth commented on Feb 17, 2026

    @marcoroth
    Owner

    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.1 that 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!

  22. marcoroth commented on Feb 17, 2026

    @marcoroth
    Owner

    Going to close this as we updated all gems now. Please feel free to re-open if you still see unexpected crashes, thank you! 🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions