Skip to content

Segmentation fault... #116

Closed
Closed

Description

@mario-sevilla

Versions
rails 5.2.1
ldclient 5.4.1
ruby 2.5.1

Implementation
initializers/launchdarkly.rb

require 'ldclient-rb'
$ld_client = LaunchDarkly::LDClient.new(ENV["LD_CLIENT_KEY"])

controllers/file_controller.rb


 before_action do |controller|
    is_feature_available("FEATURE_NAME")
  end

def is_feature_available(code)
          return true if $ld_client.variation(code, {:key => user.id}, false)

          api_error(ERROR_MSG.disabled_feature, ApiMessage::ERROR_CODE_FORBIDDEN)
end

If the feature flag is off, the first time I ran this code, everything works fine and I get the expected error. If I reload the page, I get this error

https://cl.ly/c80f0c5baba7

On the other hand if the feature is on, I get this error in the first attempt.

If I add the code directly on a controller, lets say an index endpoint, I get the same issue.

I added a puts to show the result from the variation method, first time I run it I see this, which is great

https://cl.ly/e941b403c945

If I reload I see this

https://cl.ly/d9bc8573b769

As you can see the second screenshot doesn't show the ending stars *******, nd keeps there until I get a timed out error.

If I reload a third time, I get the segmentation error from the first screenshot.

Activity

  1. eli-darkly commented on Feb 11, 2019

    @eli-darkly
    Contributor

    Sorry for the late response.

    It's unclear exactly what's going on here, but based on the stacktrace, it seems like it is a Ruby runtime issue; there's no way as far as I know for our Ruby SDK code to cause a segfault itself, since we don't have any native code. I've seen a similar report here - I say similar because in both cases the crash happens when trying to push a value onto a Queue, in Ruby 2.5.x. I've also seen segfaults with synchronization primitives in 2.5.x, as reported here - unfortunately I can't tell from that bug report whether it actually got fixed in a later version.

    As for why this would only happen when the feature flag is off, and not when it's on... I can't explain that at all. The code where the crash is happening (putting an analytics event on the event queue) will be executed the same way, with almost exactly the same values, regardless of whether the flag is off or on. So all I can imagine is that it's either a coincidence, or something timing-related (i.e. maybe the different code paths for "flag on" and "flag off" are different enough in execution time that they affect whether the buggy synchronization code in the runtime will have a problem or not).

    In any case, I'm sorry I don't have more helpful information at this point, but I do think this is very likely to be a problem with the underlying Ruby runtime. So, if possible, the first thing I would try would be using a different Ruby version.

  2. added a commit that references this issue on May 9, 2019
  3. bwoskow-ld commented on May 28, 2019

    @bwoskow-ld
    Member

    Hi Mario,

    Are you still running into this issue?

    Did you happen try running your application with a different Ruby version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions