tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

`bin/tapioca dsl` and `bin/tapioca gem --all` frequently segfault

Open francois opened this issue 3 months ago • 2 comments

Hi all! Tapioca frequently segfaults for me. This happens either when using bin/tapioca dsl or bin/tapioca gem --all.

Today was one time too many, and I finally managed to capture STDOUT/STDERR and the crash diagnostic files.

Reproduction

Sadly, I cannot give you a good recipe :disappointed: I will run the same tapioca dsl command 2, 3, 5 times in a row, and it will succeed after a couple of retries. Today, it took 5 retries to run the dsl subcommand. This morning, Tapioca crashed when I used gem --all while updating signature files for the daily Dependabot upgrade. I think it succeeded on the 2nd attempt.

What I’m running is:

$ bin/tapioca dsl

bin/tapioca is the Bundler-provided binstub:

#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'tapioca' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
  if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
    load(bundle_binstub)
  else
    abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
  end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("tapioca", "tapioca")

Environment info:

The device is a 2022 M1 MacBook Pro with 32 GB RAM. Monitor says I'm using 24 GB.

$ uname -a
Darwin MacBook-Pro-de-Francois.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000 arm64

$ ruby --version
ruby 3.4.6 (2025-09-16 revision dbd83256b1) +PRISM [arm64-darwin24]

$ bundle show | ag 'rails|sorbet|tapioca'
  * rails (7.2.2.2)
  * sorbet (0.6.12534)
  * sorbet-runtime (0.6.12534)
  * sorbet-static (0.6.12534)
  * sorbet-static-and-runtime (0.6.12534)
  * tapioca (0.17.7)

$ bundle --version
Bundler version 2.5.16

$ gem --version
3.6.9

This ZIP file contains all the *.ips from ~/Library/Logs/DiagnosticReports from today. Included is a rustc one around the time I tried to run tapioca gem --all this morning. I don't know if Tapioca or Sorbet uses Rust? segfault.zip

ruby -rrbconfig -e 'pp RbConfig::CONFIG' > rbconfig-config.txt generated this file: rbconfig-config.txt

bin/tapioca dsl 2>&1 | tee tapioca-dsl.log generated this file: tapioca-dsl.log

I'm hoping this will help someone, because this is clearly out of my depth!

francois avatar Sep 18 '25 20:09 francois

According to ChatGPT, the crash happens somewhere during PostgreSQL connection establishment while ActiveRecord is loading. I run PG 17 in a Docker container.

I tried to run lldb -- ruby -S bin/tapioca dsl and get a backtrace. The child processes that Parallel forked had all died so I couldn't get a backtrace. ChatGPT suggested I use --workers, which I did.

When using --workers 1, crashes are less frequent, if not gone altogether. I ran tapioca dsl --workers 1 in a loop, and it ran a good 6-8 times before I interrupted it. When I ran with --workers 2, it crashed on the first attempt.

This may not be a problem with Tapioca itself, then... I'll let someone else comment and close if needed.

francois avatar Sep 18 '25 20:09 francois

Given it's Postgres and I'm seeing Parallel::Deadworker can you try setting PGGSSENCMODE="disable" https://github.com/Shopify/tapioca/issues/2241#issuecomment-2748450848

KaanOzkan avatar Sep 18 '25 23:09 KaanOzkan