Free Support Forum - aspose.com

Aspose Causes Ruby Segfualt

I have found a Ruby segfault when using together with rails, cucumber, and chrome. Repro at https://github.com/bmulholland/aspose-segfault

This is crashing our test suite about 25% of the time.

Is there a better way to report bugs?

@bmulholland,

Thanks for your inquiry. Could you please share some more detail about your query what exact you want to achieve using Aspose.Words for Java?

Are you facing this issue with all documents or with specific document. Please share the exception detail along with documents. We will investigate the issue on our side and provide you more information.

The repository I linked is a full working reproduction that you can run yourself. I spent some time documenting all the detail in the readme. There is no document involved - the segfault happens simply because aspose is initialized. Here’s the stacktrace:

/usr/local/lib/ruby/2.4.0/net/http/header.rb:369: [BUG] Segmentation fault at 0x000000000000001c
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]

– Control frame information -----------------------------------------------
c:0022 p:0058 s:0116 e:000115 METHOD /usr/local/lib/ruby/2.4.0/net/http/header.rb:369
c:0021 p:0037 s:0110 e:000107 METHOD /usr/local/lib/ruby/2.4.0/net/http/header.rb:351
c:0020 p:0152 s:0104 e:000100 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/http/default.rb:
c:0019 p:0230 s:0088 e:000087 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/http/common.rb:5
c:0018 p:0141 s:0079 e:000078 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/bridge.rb:164
c:0017 p:0012 s:0070 e:000069 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/oss/bridge.rb:57
c:0016 p:0012 s:0065 e:000064 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/oss/bridge.rb:52
c:0015 p:0014 s:0060 e:000059 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/common/element.rb:199
c:0014 p:0011 s:0056 e:000055 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/selenium/node.rb:148
c:0013 p:0011 s:0051 e:000050 BLOCK /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/node/element.rb:269
c:0012 p:0046 s:0048 e:000047 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:81
c:0011 p:0009 s:0040 e:000039 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/node/element.rb:269
c:0010 p:0306 s:0036 e:000035 METHOD /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/queries/selector_query.rb:84
c:0009 p:0011 s:0028 e:000027 BLOCK /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/result.rb:29 [FINISH]
c:0008 p:---- s:0024 e:000023 IFUNC
c:0007 p:---- s:0021 e:000020 CFUNC :each
c:0006 p:---- s:0018 e:000017 CFUNC :each
c:0005 p:---- s:0015 e:000014 IFUNC
c:0004 p:---- s:0012 E:001e30 CFUNC :each
c:0003 p:---- s:0009 e:000008 CFUNC :each
c:0002 p:---- s:0006 E:0024b0 IFUNC
c:0001 p:---- s:0003 e:000002 (none) [FINISH]

– Ruby level backtrace information ----------------------------------------
/home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/bin/cucumber:0:in each' /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/bin/cucumber:0:ineach’
/home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/bin/cucumber:0:in each' /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/bin/cucumber:0:ineach’
/home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/result.rb:29:in block in initialize' /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/queries/selector_query.rb:84:inmatches_filters?’
/home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/node/element.rb:269:in visible?' /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:81:insynchronize’
/home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/node/element.rb:269:in block in visible?' /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/capybara-2.18.0/lib/capybara/selenium/node.rb:148:invisible?’
/home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/common/element.rb:199:in displayed?' /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/oss/bridge.rb:526:inelement_displayed?’
/home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/oss/bridge.rb:579:in execute' /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/bridge.rb:164:inexecute’
/home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/http/common.rb:59:in call' /home/circleci/coupa_clm/vendor/bundle/ruby/2.4.0/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/http/default.rb:104:inrequest’
/usr/local/lib/ruby/2.4.0/net/http/header.rb:351:in content_type' /usr/local/lib/ruby/2.4.0/net/http/header.rb:369:insub_type’

– Machine register context ------------------------------------------------
RIP: 0x000000000000001c RBP: 0x0000000000e15f50 RSP: 0x00007fa96409a2a8
RAX: 0x0000000000e15f50 RBX: 0x00007fa95c6b04c0 RCX: 0x0000000000000000
RDX: 0x0000000001000000 RDI: 0x0000000000e15f50 RSI: 0x00007fa95c234150
R8: 0x0000000000000000 R9: 0x000000000394f400 R10: 0x0000000000000008
R11: 0x0000000000000246 R12: 0x0000000003640000 R13: 0x0000000000000000
R14: 0x000000000347a6a0 R15: 0x00007fa96409a2d8 EFL: 0x0000000000010206

– C level backtrace information -------------------------------------------
/bin/bash: line 1: 94 Segmentation fault bundle exec cucumber features/segfault.feature

@bmulholland,

Thanks for sharing the detail. We are investigating this issue and will get back to you soon.

@bmulholland,

Thanks for your patience. We have setup the Mac operating system at our end. Could you please share the following detail for investigation?

  1. Ruby version.
  2. Rails version.
  3. Please share the application that can be used to reproduce the issue at Mac operating system.
  4. Please share all steps to reproduce this issue.

Thanks for your cooperation.

I put a lot of time into creating a simple repro with documentation about whats going on. This is linked in my original post. Have you looked at that? It has a docker container and contains all the information you’re asking for.

  1. Ruby 2.4.2: https://github.com/bmulholland/aspose-segfault/blob/master/.circleci/images/primary/Dockerfile#L1
  2. Rails 4.2.10: https://github.com/bmulholland/aspose-segfault/blob/master/Gemfile#L5
  3. Repro is the link in my original post, https://github.com/bmulholland/aspose-segfault
  4. The README in that repo: https://github.com/bmulholland/aspose-segfault#repro-steps

@bmulholland,

Thanks for sharing the detail. We are setting up the Ruby and Rails at Mac operating system and will investigate this issue. Thanks for your patience.

Because it uses a docker container, you do not need to install Ruby or Rails on your computer. Just CircleCI and Docker. I have not been able to reproduce on a Mac outside of the docker container. Likewise, I have reproduced it in the Docker container on a Debian host, as indicated in the description of that repository.

@bmulholland,

Thanks for sharing the detail. You have been able to reproduce this issue using Docker container. As per our understanding, you have not faced any issue while using Aspose.Words for Java in Ruby without docker container.

We have logged this issue as WORDSJAVA-1765 in our issue tracking system. We will inform you via this forum thread once there is any update available on it. We apologize for your inconvenience.

Thank you! Do you have an ETA for the fix? It’s really disrupting our developers’ productivity to have our test suite crashing so often.

@bmulholland,

I am afraid, there are no estimates available at the moment. We will inform you via this thread as soon as this issue is resolved. We apologize for your inconvenience.

Hi @awais.hafeez and @tahir.manzoor,

We have found a workaround for this issue: we initialize Aspose once in a rails initializer rather than initializing during each request. This avoids the segfault because the sequence of request->initialize doesn’t happen. If anyone reads this in the future, if your production server uses worker forking then you’ll need to initialize Aspose AFTER the fork.

Also, since I’m told the Asposewordsjavaforruby gem is no longer maintained (and the published gem has a bug that hasn’t been fixed in a few years), we’ve done the initialization directly without the gem. Our initializer now looks something like this:

Rjb::load(Dir.glob(Rails.root.join("lib", "aspose", "*.jar").to_s).join(':'), ['-Djava.awt.headless=true'])

fstream = Rjb::import('java.io.FileInputStream').new(Rails.root.join("lib", "aspose", "Aspose.Words.lic").to_s)

license = Rjb::import('com.aspose.words.License').new
license.setLicense(fstream)

This code runs immediately (during init) in test/dev environments. On production (& staging), it runs after Passenger starts its worker process.

Regards,
Brendan

@bmulholland,

Thanks for sharing the detail. It is nice to hear from you that you have found the workaround of this issue. We will inform you via this forum thread once there is any update available on it.

@bmulholland,

We are not maintaining the plugin since long. You have found the workaround of this issue so we have closed the issue WORDSJAVA-1765.

The issues you have found earlier (filed as WORDSJAVA-1765) have been fixed in this Aspose.Words for .NET 18.5 update and this Aspose.Words for Java 18.5 update.