Skip to content

Segmentation Fault on ruby 2.7 #199

@andy-ganchrow

Description

@andy-ganchrow

With yajl-ruby-1.4.1

Over the last week we have been experiencing a, for lack of a better word, massive issue with ruby applications just crashing intermittently

The backtrace ultimately points to the Hash#to_json, created from requiring yajl/json_gem

Removing all instances of the yajl/json_gem in favor of the json library fixed the issue, but not until today did I come up with a somewhat simple script to reproduce the same crash report

For Ubuntu 20.04, The following works on ruby2.6, but fails on 2.7.0, 2.7.2, and sometimes on 2.7.1

require 'yajl/json_gem'
a = 10000.times.map { |x| { a: 5, 1 => 'foo', b: [1, 2, 3] } }
a.each { |b| b.to_json }
require 'yajl/json_gem'
a = 10000.times.map { |x| {} }
a.each { |b| b.to_json }

No issues at all with any of the above on Ubuntu 20.10, which is an indicator its a libyaml or libjson library

Its worth noting the following does not fail ( or at least immediate enough for me to notice )

require 'yajl/json_gem'
a = 1000.times.map { |x| {} }
a.each { |b| b.to_json }

And a version that does not assign a variable but loops 10000 times does not fail either

require 'yajl/json_gem'
10000.times.each { |x| {}.to_json }

The crash report is below, and immediately what stands out to me is the backtrace appears to suggest an on_progress_callback is provided to the to_json method, which obviously its not

Let me know and I'll try to provide the differences in the installed libs on 20.10 and 20.04

https://pastebin.com/fZq0iKMQ

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