Issue #11287 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Third Party's Issue

Seems it happened in Nokogiri.

----------------------------------------
Bug #11287: XML generation, App 551 stderr: Segmentation fault at 000000000000040
https://bugs.ruby-lang.org/issues/11287#change-53060

* Author: Simon Toivo Telhaug
* Status: Third Party's Issue
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
We have a page that should deliver XML. We have newly upgraded ruby from 1.9.3 to 2.2.2 and rails 3.2.17 to 4.2.1
Our server is using nginx and passenger to receive requests

When we are access our server and get the XML we get the respond 
notice that all other pages is working

~~~xml
<hash>
  <status>500</status>
  <error>Internal Server Error</error> 
</hash>
~~~
or


Incomplete response received from application
Sometimer In Rails production log we get one of the following errors:

~~~
Completed 500 Internal Server Error in 19815ms (ActiveRecord: 17628.6ms)

RuntimeError (unsupported: FalseClass):
lib/bank_transaction_xml/bt_to_xml.rb:43:in `block (4 levels) in to_xml'
lib/bank_transaction_xml/bt_to_xml.rb:31:in `block (3 levels) in to_xml'
lib/bank_transaction_xml/bt_to_xml.rb:29:in `block (2 levels) in to_xml'
lib/bank_transaction_xml/bt_to_xml.rb:6:in `block in to_xml'
lib/bank_transaction_xml/bt_to_xml.rb:5:in `new'
lib/bank_transaction_xml/bt_to_xml.rb:5:in `to_xml'
lib/bank_transaction_xml/bt_to_xml.rb:227:in `block (3 levels) in list_xml'
lib/bank_transaction_xml/bt_to_xml.rb:226:in `each'
lib/bank_transaction_xml/bt_to_xml.rb:226:in `block (2 levels) in list_xml'
lib/bank_transaction_xml/bt_to_xml.rb:222:in `block in list_xml'
lib/bank_transaction_xml/bt_to_xml.rb:221:in `new'
lib/bank_transaction_xml/bt_to_xml.rb:221:in `list_xml'
app/controllers/balance_report_controller.rb:91:in `block (2 levels) in index'
app/controllers/balance_report_controller.rb:88:in `index'

ActiveModel::MissingAttributeError (missing attribute: account_number):
lib/bank_transaction_xml/bt_to_xml.rb:7:in `block (3 levels) in to_xml'
lib/bank_transaction_xml/bt_to_xml.rb:7:in `block (2 levels) in to_xml'
lib/bank_transaction_xml/bt_to_xml.rb:6:in `block in to_xml'
...


ArgumentError (string contains null byte):
lib/bank_transaction_xml/bt_to_xml.rb:11:in `block (3 levels) in to_xml'
lib/bank_transaction_xml/bt_to_xml.rb:11:in `block (2 levels) in to_xml'
...


NoMethodError (undefined method `type_cast_from_database' for false:FalseClass):
app/models/invoice.rb:1853:in `check_delete_at'
lib/bank_transaction_xml/bt_to_xml.rb:34:in `block (5 levels) in to_xml'
...
~~~

Most of the time passenger is logging this, and than we don't get any errorin production log , (uploaded file with log)

~~~
App 551 stderr: /fakturabank_path/shared/bundle/ruby/2.2.0/gems/nokogiri-1.6.6.2/lib/nokogiri/xml/document.rb:82: [BUG]
App 551 stderr: Segmentation fault at 000000000000040
App 551 stderr: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
..

App 551 stderr:
App 551 stderr: [NOTE]
App 551 stderr: You may have encountered a bug in the Ruby interpreter or extension libraries.
App 551 stderr: Bug reports are welcome.
App 551 stderr: For details: http://www.ruby-lang.org/bugreport.html
App 551 stderr:
[ 2015-06-18 09:45:33.5083 25387/7fcac95af700 age/Hel/Req/Utils.cpp:89 ]: [Client 2-1569] Sending 502 response: application did not send a complete response
[ 2015-06-18 09:45:36.0178 25387/7fcad02f2700 App/Poo/AnalyticsCollection.h:93 ]: Process (pid=1805, group=/fakturabank_path/current/public (staging)#default) no longer exists! Detaching it from the pool.
[ 2015-06-18 09:45:36.0180 25387/7fcad02f2700 age/Hel/Main.cpp:732 ]: Disconnecting long-running connections for process 1805, application /fakturabank_path/current/public (staging)#default
App 24184 stdout:
~~~

When we are doing this in development environment it all works good, it still take time. If we use less data it work on server and on development. Andit nota specific point it breaks.

example 
    5 bank transaction always work 
  50 bank transaction work from time to time like 5 out of 10 
100 bank transaction never work

I have tried to downgrade ruby version to 2.1.0, no luck there. Alse I tried to downgrade ruby version to 2.0.0, it works a lot better but still not all the time.

Why?? I thing it is something with passenger and ruby 2.1 and 2.2? 
what i can to to keep using ruby 2.2.2

---Files--------------------------------
nginx_error.log (353 KB)


-- 
https://bugs.ruby-lang.org/