From: "ioquatix (Samuel Williams) via ruby-core" Date: 2024-01-14T22:09:03+00:00 Subject: [ruby-core:116208] [Ruby master Bug#20184] Ruby segfaults on Fly.io with 256 MB RAM Issue #20184 has been updated by ioquatix (Samuel Williams). I was also investigating this issue. On low-memory systems (< ~400MB RAM+Swap), `Init_default_shapes` will fail and cause Ruby to segfault later. Even something as simple as ruby -e "puts 123" will fail. The 2nd `mmap` in `shape.c` tries to allocate 384MB as a cache. This fails with `MAP_FAILED` which is stored into a `shape_cache` pointer and later this pointer is derefenced causing a segfault. The current merged fix skips the cache if the `mmap` fails, but might I suggest we explore the following: - Divide and conquer strategy for finding an allocation size that works (e.g. divide by half and try again a few times). - Expose an environment variable to control the size, so that those on memory constrained systems can at least enable a smaller cache. ---------------------------------------- Bug #20184: Ruby segfaults on Fly.io with 256 MB RAM https://bugs.ruby-lang.org/issues/20184#change-106228 * Author: aalin (Andreas Alin) * Status: Closed * Priority: Normal * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux] * Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED ---------------------------------------- I've been running a Ruby 3.2 app on Fly.io with 256 MB RAM and it has been working fine. When I upgraded to Ruby 3.3.0, any Ruby script would crash immediately with a segfault. I haven't been able to reproduce it outside of fly.io. I created a repository with a basic rack app which crashes on fly.io. The readme includes the full output and a GDB backtrace. https://github.com/aalin/ruby-3-3-0-fly-crash -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/