为什么测试期间我的ruby崩溃/ segfault?

我读过的地方可能与sqlite3有关,但是我的谷歌搜索没有任何帮助。 这里是一个错误的例子:https://travis-ci.org/NullVoxPopuli/aeonvera/jobs/61047991

它似乎随机发生 - 无论是在我的机器上还是在Travis上。 所以我最终不得不重新运行rspec直到它通过 - 这非常烦人,因为我的测试套件需要几分钟才能运行。

这是如何造成的? 我如何防止它? 有必要积极地与你的CI进行交流,以重新运行规范,直到它通过。

我使用sqlite3在内存中运行我的所有规格 - 这是一个很好的速度奖金,并且还帮助我确保没有执行任何特定于数据库的查询(我的生产应用程序使用pgsql)

这里有一个链接到我的回购,如果有人很好奇:https://github.com/NullVoxPopuli/aeonvera

UPDATE

这不是sqlite3特有的 - 它也发生在使用postgresql时。

堆栈跟踪

/home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/connection_adapters/postgresql/database_statements.rb:128: [BUG] Segmentation fault at 0x000000000001d4
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0057 p:---- s:0311 e:000310 CFUNC  :backtrace
c:0056 p:0009 s:0310 e:000309 RESCUE /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/notifications/instrumenter.rb:25
c:0055 p:0037 s:0307 e:000305 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/notifications/instrumenter.rb:25
c:0054 p:0034 s:0300 e:000299 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/connection_adapters/abstract_adapter.rb:378
c:0053 p:0014 s:0292 e:000291 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/connection_adapters/postgresql/database_statement
c:0052 p:0019 s:0286 e:000286 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/connection_adapters/abstract/savepoints.rb:17
c:0051 p:0014 s:0283 e:000282 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/connection_adapters/abstract/transaction.rb:114
c:0050 p:0009 s:0280 e:000279 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/connection_adapters/abstract/database_statements.
c:0049 p:0018 s:0277 e:000276 RESCUE /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/connection_adapters/abstract/database_statements.
c:0048 p:0035 s:0274 e:000272 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/connection_adapters/abstract/database_statements.
c:0047 p:0078 s:0267 e:000266 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/connection_adapters/abstract/database_statements.
c:0046 p:0017 s:0263 e:000262 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/transactions.rb:208
c:0045 p:0014 s:0262 E:001878 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activerecord-4.1.10/lib/active_record/transactions.rb:326
c:0044 p:0010 s:0256 e:000255 RESCUE
c:0043 p:---- s:0225 e:000221 CFUNC  :initialize_copy
c:0042 p:---- s:0221 e:000220 CFUNC  :unlock
c:0041 p:0024 s:0223 e:000220 BLOCK  /home/preston/.rvm/gems/ruby-2.2.1/gems/railties-4.1.10/lib/rails/backtrace_cleaner.rb:10 [FINISH]
c:0040 p:---- s:0218 e:000217 CFUNC  :call
c:0039 p:0012 s:0214 e:000213 BLOCK  /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/backtrace_cleaner.rb:85 [FINISH]
c:0038 p:---- s:0211 e:000210 CFUNC  :map
c:0037 p:0010 s:0208 e:000207 BLOCK  /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/backtrace_cleaner.rb:85 [FINISH]
c:0036 p:---- s:0205 e:000204 CFUNC  :each
c:0035 p:0011 s:0202 e:000201 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/backtrace_cleaner.rb:84
c:0034 p:0015 s:0198 e:000197 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/backtrace_cleaner.rb:37
c:0033 p:0025 s:0192 e:000191 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/actionpack-4.1.10/lib/action_dispatch/middleware/exception_wrapper.rb:89
c:0032 p:0009 s:0188 e:000187 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/actionpack-4.1.10/lib/action_dispatch/middleware/exception_wrapper.rb:49
c:0031 p:0037 s:0185 e:000184 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/actionpack-4.1.10/lib/action_dispatch/middleware/debug_exceptions.rb:74
c:0030 p:0028 s:0177 e:000176 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/actionpack-4.1.10/lib/action_dispatch/middleware/debug_exceptions.rb:34
c:0029 p:0045 s:0166 e:000165 RESCUE /home/preston/.rvm/gems/ruby-2.2.1/gems/actionpack-4.1.10/lib/action_dispatch/middleware/debug_exceptions.rb:27
c:0028 p:0091 s:0163 e:000162 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/actionpack-4.1.10/lib/action_dispatch/middleware/debug_exceptions.rb:17
c:0027 p:0011 s:0154 e:000153 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/actionpack-4.1.10/lib/action_dispatch/middleware/show_exceptions.rb:30
c:0026 p:0077 s:0149 e:000148 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/railties-4.1.10/lib/rails/rack/logger.rb:38
c:0025 p:0011 s:0142 e:000141 BLOCK  /home/preston/.rvm/gems/ruby-2.2.1/gems/railties-4.1.10/lib/rails/rack/logger.rb:20
c:0024 p:0007 s:0140 e:000139 BLOCK  /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/tagged_logging.rb:68
c:0023 p:0018 s:0138 e:000137 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/tagged_logging.rb:26
c:0022 p:0013 s:0133 e:000132 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/tagged_logging.rb:68
c:0021 p:0042 s:0129 e:000128 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/railties-4.1.10/lib/rails/rack/logger.rb:20
c:0020 p:0077 s:0124 e:000123 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/quiet_assets-1.1.0/lib/quiet_assets.rb:27
c:0019 p:0011 s:0120 e:000119 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/request_store-1.1.0/lib/request_store/middleware.rb:8
c:0018 p:0031 s:0116 e:000115 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/actionpack-4.1.10/lib/action_dispatch/middleware/request_id.rb:21
c:0017 p:0071 s:0112 e:000111 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/methodoverride.rb:21
c:0016 p:0024 s:0107 e:000106 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/runtime.rb:17
c:0015 p:0035 s:0098 e:000097 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/activesupport-4.1.10/lib/active_support/cache/strategy/local_cache_middleware.rb:26
c:0014 p:0091 s:0093 e:000092 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/actionpack-4.1.10/lib/action_dispatch/middleware/static.rb:84
c:0013 p:0011 s:0087 e:000086 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/sendfile.rb:112
c:0012 p:0058 s:0077 e:000076 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/railties-4.1.10/lib/rails/engine.rb:514
c:0011 p:0036 s:0073 e:000072 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/railties-4.1.10/lib/rails/application.rb:144
c:0010 p:0011 s:0069 e:000068 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/builder.rb:138
c:0009 p:0148 s:0065 e:000064 BLOCK  /home/preston/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/urlmap.rb:65 [FINISH]
c:0008 p:---- s:0057 e:000056 CFUNC  :each
c:0007 p:0054 s:0054 e:000053 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/urlmap.rb:50
c:0006 p:0045 s:0045 e:000044 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/capybara-2.4.4/lib/capybara/server.rb:19
c:0005 p:0301 s:0040 e:000039 METHOD /home/preston/.rvm/gems/ruby-2.2.1/gems/rack-1.5.3/lib/rack/handler/webrick.rb:60
c:0004 p:0211 s:0028 e:000027 METHOD /home/preston/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138
c:0003 p:0370 s:0018 e:000017 METHOD /home/preston/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94
c:0002 p:0103 s:0007 e:000006 BLOCK  /home/preston/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294 [FINISH]
c:0001 p:---- s:0002 e:000001 TOP    [FINISH]

所有其他信息:http://pastebin.com/d6Tm13ww


你可以尝试退回你的git历史,直到你有一个稳定的状态。 并从那里引入更改以隔离“不良”变化。

另外,即使在测试中,也应该避免使用sqlite3。 测试应尽可能接近生产。

链接地址: http://www.djcxy.com/p/26031.html

上一篇: Why does my ruby crash / segfault during tests?

下一篇: How to add space to AutoCompleteTextView suggestion