Skip to content

Segfault under Rack/Passenger #22

@aaronbarnett

Description

@aaronbarnett

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions