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

Segfault under Rack/Passenger #22

Open
aaronbarnett opened this issue Mar 27, 2014 · 6 comments
Open

Segfault under Rack/Passenger #22

aaronbarnett opened this issue Mar 27, 2014 · 6 comments

Comments

@aaronbarnett
Copy link

Using rsruby in a sinatra/rack app.

def initialize(app)
    super(app)
    @r = RSRuby.instance
end

get '/test.json' do
    content_type 'text/plain'
    out = @r.seq(1,9)
    out.to_json
end

The calls to R work as expected in irb and when ruby is run from the command line. They fail when run through rackup or with passenger. Log contains a lot of this...

App 29404 stderr: Error during wrapup: C stack usage is too close to the limit
App 29404 stderr: Error during wrapup: C stack usage is too close to the limit
App 29404 stderr: Error during wrapup: C stack usage is too close to the limit
App 29404 stderr: Error during wrapup: C stack usage is too close to the limit
App 29404 stderr: Error during wrapup: C stack usage is too close to the limit

In rsruby.rb I commented out the error trapping

#Catch errors
# self.__init_eval_R__("options(error=expression(NULL))")
#disable errors
# self.__init_eval_R__("options(show.error.messages=F)")

This reveals a little more detail

App 27581 stderr:  *** caught segfault ***
App 27581 stderr: address 0x11000088, cause 'memory not mapped'
App 27581 stderr: aborting ...
[ 2014-03-26 16:20:36.8674 27558/0x1091c2000 Pool2/SmartSpawner.h:689 ]: An error occurred while spawning a process: An error occurred while starting the web application. It exited before signalling successful startup back to Phusion Passenger.
[ 2014-03-26 16:20:36.8674 27558/0x1091c2000 Pool2/SmartSpawner.h:690 ]: The application preloader seems to have crashed, restarting it and trying again...

Moving the call to RSRuby.instance into the controller causes similar errors. Also if @r.seq(1,9) is moved into the initialize block it performs as expected. It seems that the controller environment is where any reference into rsruby fails.

@stanley90
Copy link

I'm experiencing similar failures, having the RSRuby instance in the application controller, and running capybara tests. Started failing with "segfault" and "stack smashing detected" after upgrading capybara from 1.1.4 to 2.x.

@linojon
Copy link

linojon commented May 9, 2014

We're experiencing very similar problems, after upgrading from Passenger 3 to Passenger 4. Happens running ruby 1.9.3 as well as 2.1.1, and Rails 3.2 as well as 4.0. Runs fine when calling R through RSRuby in the rails console, but gets "C stack usage is too close to the limit" and then segfault in the Apache log

@eliagilad
Copy link

I've noticed that it works just fine with Unicorn, but not with WEBrick or Sidekiq.
Any idea how to solve it?

@athityakumar
Copy link

athityakumar commented Aug 8, 2017

Has anyone found a workaround for this yet? I'm facing the same issue with Rails 5.1.3.

@athityakumar
Copy link

Hey all. Strangely enough, athityakumar@bf2b0f4 fixed the issue for me. However, I'm not sure if it's a good approach to comment out the RException class.

@alexgutteridge - Please guide me if something is wrong with that commit. I can work on a PR. 😄

@altrabio
Copy link

I am facing the same kind of issue (passenger 4.0.37, ruby 1.9.3) ? The fix proposed by athityakumar does not work for me. Has anyone another workaround. (Note that the segmentation fault is not systematic).
Thanks

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

No branches or pull requests

6 participants