Faker: Weird crash with Faker 1.8.3

Created on 13 Jul 2017  路  11Comments  路  Source: faker-ruby/faker

On OS X 10.12.5 with ruby 2.4.1 I'm seeing this crash when rendering a rails email preview:

19:51:13 web.1          | /Users/bart/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/faker-1.8.3/lib/faker.rb:200: [BUG] Segmentation fault at 0x00000000000000
19:51:13 web.1          | ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
19:51:13 web.1          | 
19:51:13 web.1          | -- Crash Report log information --------------------------------------------
19:51:13 web.1          |    See Crash Report log file under the one of following:
19:51:13 web.1          |      * ~/Library/Logs/DiagnosticReports
19:51:13 web.1          |      * /Library/Logs/DiagnosticReports
19:51:13 web.1          |    for more details.
19:51:13 web.1          | Don't forget to include the above Crash Report log file in bug reports.
19:51:13 web.1          | 
19:51:13 web.1          | -- Control frame information -----------------------------------------------
19:51:13 web.1          | c:0091 p:---- s:0642 e:000641 CFUNC  :sample
19:51:13 web.1          | c:0090 p:0030 s:0637 e:000636 METHOD /Users/bart/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/faker-1.8.3/lib/faker.rb:200
19:51:13 web.1          | c:0089 p:0019 s:0632 e:000631 METHOD /Users/bart/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/faker-1.8.3/lib/faker.rb:98
19:51:13 web.1          | c:0088 p:0010 s:0626 e:000625 METHOD /Users/bart/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/faker-1.8.3/lib/faker.rb:122
19:51:13 web.1          | c:0087 p:0010 s:0619 e:000618 METHOD /Users/bart/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/faker-1.8.3/lib/faker/name.rb:8

It's called in my code like this: FactoryGirl.attributes_for(:incoming, from: "#{Faker::Name.name} <#{Faker::Internet.email}>")
But calling Faker::Name.name in the rails console does not reproduce this.

Rolling back to faker 1.7.3 clears up the crash.

Most helpful comment

This bug should be closed now as 3 new Ruby versions had been released, see https://www.ruby-lang.org/en/news/2017/09/14/ruby-2-4-2-released/.

https://bugs.ruby-lang.org/issues/13753 is closed too

Ruby 2.4.2 and 2.3.5 does'nt segfault any more. I personnaly did'nt try 2.2.8.

All 11 comments

EDIT: macOs v10.12.5 and ruby 2.3.3. And reverting to 1.7.3 didn't fix it for me.
EDIT EDIT: Removed stacktrace, I wasn't having the same issue.

I dug some more, correct me if this is a separate issue from Viamin's, but this old issue https://github.com/rails/rails/issues/3488 suggests adding psych directly into the Gemfile. I did this and faker works at whatever version again. @viamin does this fix the issue for you or am I experiencing something different?

I already had psych in my Gemfile (because of https://github.com/rails/rails/issues/3488) when I hit this issue.

@viamin's issue may well be caused by a Ruby bug which shows up as faker > 1.8.0 uses Random::DEFAULT by default: https://github.com/stympy/faker/blob/6148f01b4f2755358e4dd4928a438be9e55fb11b/lib/faker.rb#L37

That Ruby issue is fixed in https://github.com/ruby/ruby/commit/a14cb8ad5b432bcda7b6a4a0ee41a1a292d0b568 so you could try compiling a Ruby from trunk to see if it solves the issue. I believe the Ruby fix is scheduled to be backported for the next 2.2, 2.3 and 2.4 releases

Thanks for the info, @owst!

I can confirm this too :)

I can also reproduce this issue, but we're using Ruby 2.3.4, RSpec 3.6 and it only happens when we use it with Zeus (any version).

For now, I'm adding this to my spec helper as a workaround while the ruby bug fix is not published:

Faker::Config.random = Random.new

This bug should be closed now as 3 new Ruby versions had been released, see https://www.ruby-lang.org/en/news/2017/09/14/ruby-2-4-2-released/.

https://bugs.ruby-lang.org/issues/13753 is closed too

Ruby 2.4.2 and 2.3.5 does'nt segfault any more. I personnaly did'nt try 2.2.8.

Thanks, @yld!

FWIW, beware the "innocuous" point update from 2.4.1 to 2.4.2

https://github.com/bbatsov/rubocop/issues/4793

There is a breaking change in syntax...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gerryhd picture gerryhd  路  3Comments

elangovan-selvaraj picture elangovan-selvaraj  路  6Comments

KelseyDH picture KelseyDH  路  4Comments

kevgathuku picture kevgathuku  路  4Comments

benpolinsky picture benpolinsky  路  5Comments