Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault #409

Closed
marcelolx opened this issue Dec 7, 2024 · 6 comments
Closed

Segmentation fault #409

marcelolx opened this issue Dec 7, 2024 · 6 comments
Labels

Comments

@marcelolx
Copy link

Describe the bug
I created a fresh Rails 8 app, with a User model that can have an avatar, and when Rails runs ActiveStorage::AnalyzeJob to analyze the image attached to the User, I have been seeing a segmentation fault that is happening in ruby-vips.

By checking some issues in this repo, I saw this comment from @jcupitt about the FFI gem. So, I changed my Gemfile to use the 1.16.3 version of FFI to see if it would solve the issue, and in fact, it did — The analyze job ran successfully and I haven't seen any segmentation fault anymore.

So, it seems to be something with the FFI v1.17.0 gem, but I am opening the bug report here because I guess someone here might have a better idea of what's going on (so then we can open an issue there)

Desktop:

  • OS: MacOS Sequia 15.1.1 (M1)
  • Ruby: 3.3.0
  • Ruby-Vips: 2.2.2
    • FFI: 1.17.0

Additional context

Attached is the full stack trace of the error (too many chars to post in the issue here)

segmentation fault.txt

@marcelolx marcelolx added the bug label Dec 7, 2024
@marcelolx
Copy link
Author

I wonder if it is because 1.16.3 installs the ruby version while 1.17.0 seems to have the version specific for a given platform 🤔

image

@jcupitt
Copy link
Member

jcupitt commented Dec 8, 2024

Hello again,

This was working for me on macOS last time I tried :( I'll have a another go.

@jcupitt
Copy link
Member

jcupitt commented Dec 8, 2024

It all seems to work for me, sorry :(

Where is your ruby from? I'm getting everything from homebrew:

11:38 $ ruby --version
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin23]
✔ ~/pics 
11:40 $ gem info ffi ruby-vips

*** LOCAL GEMS ***

ffi (1.17.0)
    Platform: arm64-darwin
    Author: Wayne Meissner
    Homepage: https://github.com/ffi/ffi/wiki
    License: BSD-3-Clause
    Installed at: /opt/homebrew/lib/ruby/gems/3.3.0

    Ruby FFI

*** LOCAL GEMS ***

ruby-vips (2.2.2)
    Author: John Cupitt
    Homepage: http://github.com/libvips/ruby-vips
    License: MIT
    Installed at: /opt/homebrew/lib/ruby/gems/3.3.0

    A fast image processing library with low memory needs
✔ ~/pics 
11:40 $ which ruby
/opt/homebrew/opt/ruby/bin/ruby
✔ ~/pics 

@jcupitt
Copy link
Member

jcupitt commented Dec 8, 2024

.. and I tested it with:

11:37 $ irb
irb(main):001> require "vips"
=> true
irb(main):002> x = Vips::Image.new_from_file("k2.jpg")
=> #<Image 1450x2048 uchar, 3 bands, srgb>
irb(main):003> x = x.fliphor()
=> #<Image 1450x2048 uchar, 3 bands, srgb>
irb(main):005> x.write_to_file "x.jpg"
=> nil
irb(main):006> 

@kleisauke
Copy link
Member

Given that the stack trace references Puma, I wonder if this relates to #155. Does the issue still occur on macOS if you set the OBJC_DISABLE_INITIALIZE_FORK_SAFETY=yes environment variable?

Alternatively, you might try the workaround suggested in #155 (comment).

@marcelolx
Copy link
Author

@kleisauke so I already had that environment variable set (because I was having that exact issue before)

What I did was to run brew upgrade to upgrade all my deps + upgrade to ruby 3.3.6 — and now it is just working with FFI v1.17 🤷

My Ruby comes from asdf @jcupitt

Anyway guys, thanks for the hints, I guess it was something with some outdated dependency (I hadn't run brew upgrade for a quite long time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants