Skip to content

Segmentation fault on Jenkins #7

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

Closed
bf4 opened this issue Sep 11, 2013 · 14 comments
Closed

Segmentation fault on Jenkins #7

bf4 opened this issue Sep 11, 2013 · 14 comments

Comments

@bf4
Copy link
Contributor

bf4 commented Sep 11, 2013

full gist

jenkins shell commands are

#!/bin/bash -x
bundle --deployment --quiet --binstubs --without development jruby && CODECLIMATE_REPO_TOKEN=itsasecret bin/rake ci

Where rake ci does stuff and calls ENV['CODECLIMATE_REPO_TOKEN']='itsasecret' then Rake::Task['ci:spec'].invoke(*args)

Finished in 29/12 minutes 1 second
639 examples, 0 failures, 21 pending

Randomized with seed 13245

Coverage = 67.14%./var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:50: [BUG] Segmentation fault
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0013 p:---- s:0055 b:0055 l:000054 d:000054 CFUNC  :round
c:0012 p:0198 s:0051 b:0042 l:000033 d:000041 BLOCK  /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test
c:0011 p:---- s:0039 b:0039 l:000038 d:000038 FINISH
c:0010 p:---- s:0037 b:0037 l:000036 d:000036 CFUNC  :map
c:0009 p:0037 s:0034 b:0034 l:000033 d:000033 METHOD /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test
c:0008 p:0046 s:0028 b:0028 l:000027 d:000027 METHOD /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test
c:0007 p:0030 s:0020 b:0020 l:000019 d:000019 METHOD /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/result.rb:91
c:0006 p:0021 s:0017 b:0017 l:001d00 d:000016 BLOCK  /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/configuration.rb:133
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 FINISH
c:0004 p:---- s:0013 b:0013 l:000012 d:000012 CFUNC  :call
c:0003 p:0070 s:0010 b:0010 l:0025e0 d:000009 BLOCK  /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001618 d:001618 TOP

-- Ruby level backtrace information ----------------------------------------
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52:in `block in <top (required)>'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52:in `call'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/configuration.rb:133:in `block in at_exit'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/result.rb:91:in `format!'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:12:in `format'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:40:in `to_payload'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:40:in `map'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:50:in `block in to_payload'
/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:50:in `round'

-- C level backtrace information -------------------------------------------
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x181b57) [0x7f47d13dfb57] vm_dump.c:796
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x61fb4) [0x7f47d12bffb4] error.c:258
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(rb_bug+0xb8) [0x7f47d12c0158] error.c:277
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x111245) [0x7f47d136f245] signal.c:609
/lib/libpthread.so.0(+0xeff0) [0x7f47d1050ff0]
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0xe1594) [0x7f47d133f594] rational.c:1195
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0xe1aa6) [0x7f47d133faa6] rational.c:1233
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x18021f) [0x7f47d13de21f] vm_insnhelper.c:404
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x171a92) [0x7f47d13cfa92] insns.def:1018
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x1764e9) [0x7f47d13d44e9] vm.c:1227
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(rb_yield+0x66) [0x7f47d13d7c06] vm.c:661
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x36615) [0x7f47d1294615] array.c:2238
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x18021f) [0x7f47d13de21f] vm_insnhelper.c:404
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x171a92) [0x7f47d13cfa92] insns.def:1018
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x1764e9) [0x7f47d13d44e9] vm.c:1227
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x17797c) [0x7f47d13d597c] vm.c:631
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x6e1da) [0x7f47d12cc1da] proc.c:561
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x18021f) [0x7f47d13de21f] vm_insnhelper.c:404
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x171a92) [0x7f47d13cfa92] insns.def:1018
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x1764e9) [0x7f47d13d44e9] vm.c:1227
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x17797c) [0x7f47d13d597c] vm.c:631
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(rb_exec_end_proc+0x1ef) [0x7f47d12c4f4f] eval_jump.c:126
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(+0x66ff7) [0x7f47d12c4ff7] eval.c:92
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(ruby_cleanup+0x132) [0x7f47d12c5172] eval.c:133
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/libruby.so.1.9(ruby_run_node+0x25) [0x7f47d12c5485] eval.c:244
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/bin/ruby() [0x4009bb] main.c:38
/lib/libc.so.6(__libc_start_main+0xfd) [0x7f47d0439c8d]
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/bin/ruby() [0x4008a9]

-- Other runtime information -----------------------------------------------

* Loaded script: /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/bin/rspec

* Loaded features:

    0 enumerator.so
    1 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
    2 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
    3 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/defaults.rb
    4 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb
    5 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/deprecate.rb
    6 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/exceptions.rb
    7 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
    8 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems.rb
    9 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/pathname.so
   10 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/pathname.rb
   11 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/version.rb
   12 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/etc.so
   13 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb
   14 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb
   15 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb
   16 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/platform.rb
   17 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb
   18 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/path_support.rb
   19 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/syntax_error.rb
   20 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/psych.so
   21 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/x86_64-linux/stringio.so
   22 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/nodes/node.rb
   23 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/nodes/stream.rb
   24 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/nodes/document.rb
   25 /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych/nodes/sequence.rb

<snip>

7f47d18b5000-7f47d18b6000 rw-p 00000000 00:00 0
7fff9a01a000-7fff9a030000 rw-p 00000000 00:00 0                          [stack]
7fff9a14c000-7fff9a14d000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]


[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
@bf4
Copy link
Contributor Author

bf4 commented Sep 11, 2013

It fails on JRuby 1.7.4 for this app, also.

@brynary
Copy link
Member

brynary commented Sep 11, 2013

Hey -- Sorry you've run into an issue. What behavior are you seeing under JRuby?

Also -- Are you able to try the latest patchlevel of 1.9.3 on MRI?

@bf4
Copy link
Contributor Author

bf4 commented Sep 11, 2013

Oh, I should have said I also ran it with mri 1.9.3-p448

The JRuby failure might be a red herring. It ran out of memory. That's why I added it as an afterthought.

@brynary
Copy link
Member

brynary commented Sep 17, 2013

Got it. Can you confirm you are able to run with standard SimpleCov and generate one of it's HTML reports? Our code does not do much beyond SimpleCov (just an HTTPS POST).

@ecbypi
Copy link

ecbypi commented Sep 18, 2013

I am having the same problem on a Rails project that is using ruby 1.9.3-p448. SimpleCov reports work just fine.

@brynary
Copy link
Member

brynary commented Sep 18, 2013

@ecbypi -- Can you also paste your full output into a comment or Gist?

Unfortunately, since our gem is pure Ruby and pretty simple, I don't see how we could be causing a segfault. It feels like it would have to be a bug in SimpleCov or Ruby. Since SimpleCov reports are working okay (for @ecbypi at least), it may be a bug in MRI. (Since the contract as I understand it is that: No pure Ruby code is supposed to trigger a segfault.)

@bf4
Copy link
Contributor Author

bf4 commented Sep 18, 2013

Found it, submitted a fix PR in #15, unfortunately, had some typos and I'm doing this via the Web UI.

@bf4 bf4 closed this as completed Sep 18, 2013
@ecbypi
Copy link

ecbypi commented Sep 18, 2013

I can confirm that @bf4's patch fixes the issue for me as well.

@noahd1
Copy link
Contributor

noahd1 commented Sep 18, 2013

I am a bit confused about this for a couple reasons.

  1. I'm unable to replicate the segfault with the same version/patchlevel of MRI:

    [1.9.3-p448][17:31][~/p/ruby-test-reporter (master)]$ ruby --version
    ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]
    [1.9.3-p448][17:31][~/p/ruby-test-reporter (master)]$ irb
    >> Float(800/22).round(2)
    => 36.0
    
  2. There seems to be 1 line that wasn't changed and it seems like if the issue is as reported, the code would still be blowing up:

https://github.com/bf4/ruby-test-reporter/blob/b77c488c40e53e149d136d7b97dfa821c7b97656/lib/code_climate/test_reporter/formatter.rb#L10

@bf4
Copy link
Contributor Author

bf4 commented Sep 18, 2013

@noahd1 Thanks for reviewing this

re: reproducing it, apparently the way that the rational (800/22) was output isn't the same as typing (800/22) in irb. My bad. I don't know much about Rationals in ruby.

re: the missed change (oops): the failing method for me was specifically "file.covered_percent", so I guess "result.covered_percent.round(2)" is a Float or something valid for rounding. "file.covered_strength" for example, didn't need to be converted to a Float.

@bf4
Copy link
Contributor Author

bf4 commented Sep 18, 2013

@noahd1 Normally my submission would be higher quality and I'd rebase it.. but for reasons I only have access to the github web UI right now... I apologize for that.

@bf4
Copy link
Contributor Author

bf4 commented Sep 18, 2013

Looks like the number that blows up is actually the rational (200/10)

This was reproducible in the context of my test, but not in a regular session

covered_percent = Marshal.load("\x04\bU:\rRational[\ai\x01\xC8i\x0F")
covered_percent.round(2)

The YAML dump is "--- !ruby/object:Rational\ndenominator: 10\nnumerator: 200\n"

@bf4
Copy link
Contributor Author

bf4 commented Sep 18, 2013

I'll follow up on this at home tonight to track down which gem needs to be required to cause the segfault when running the above code. It's something in my test environment after rails loads.

@noahd1
Copy link
Contributor

noahd1 commented Sep 18, 2013

Thanks Ben. Sounds worthwhile. Otherwise we could end up inadvertently reproducing this behavior later.

bf4 added a commit to bf4/ruby-test-reporter that referenced this issue Sep 18, 2013
For a covered percent of Rational(200/10)
covered_percent = Marshal.load("\x04\bU:\rRational[\ai\x01\xC8i\x0F")
covered_percent.round(2) => segfault
Float(covered_percent).round(2) => 20.0

The segfault depends on as yet unknown gems to be required
pbrisbin added a commit that referenced this issue Dec 27, 2016
Simplecov supports merging coverage from multiple test suites by writing them at
different command names in the resultset file, then merging them when building
the report.

We were getting this for free pre-1.0 because the resultsets would be merged
before being passed to the custom formatter. Post-1.0 we were (mistakenly)
assuming it'd just be one command name in the JSON file, hence we were only
reading:

    SimpleCov::Result.new(results.values.fetch(0).fetch("coverage"))

discarding all but the first command-name.

This is both broken and more work than we need to do. The file has a
well-defined schema, and we can rely more on Simplcov for parsing it.

Something like:

    SimpleCov::Result.from_hash(results.first)

would've been functionally equivalent, and shows more clearly the bug. What we
really want is:

    results.map do |k, v|
      SimpleCov::Result.from_hash(k => v)
    end

Then with an array of results, we can in-line some of Simplecov::ResultMerger to
merge them together into a single Simplecov::Result that we'll format for
upload. Unfortunately, we do have to in-line the method we need because this
object has multiple responsibilities (yay!), including caching and re-writing
files on disk, which we _don't_ want.

Fixes #7
maxjacobson pushed a commit that referenced this issue Dec 29, 2016
Simplecov supports merging coverage from multiple test suites by writing them at
different command names in the resultset file, then merging them when building
the report.

We were getting this for free pre-1.0 because the resultsets would be merged
before being passed to the custom formatter. Post-1.0 we were (mistakenly)
assuming it'd just be one command name in the JSON file, hence we were only
reading:

    SimpleCov::Result.new(results.values.fetch(0).fetch("coverage"))

discarding all but the first command-name.

This is both broken and more work than we need to do. The file has a
well-defined schema, and we can rely more on Simplcov for parsing it.

Something like:

    SimpleCov::Result.from_hash(results.first)

would've been functionally equivalent, and shows more clearly the bug. What we
really want is:

    results.map do |k, v|
      SimpleCov::Result.from_hash(k => v)
    end

Then with an array of results, we can in-line some of Simplecov::ResultMerger to
merge them together into a single Simplecov::Result that we'll format for
upload. Unfortunately, we do have to in-line the method we need because this
object has multiple responsibilities (yay!), including caching and re-writing
files on disk, which we _don't_ want.

Fixes #7
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

4 participants