Open ylansegal opened 5 years ago
In addition, I can also reproduce -- to a certain extent -- when the garbage collector runs, even if the connection is not closed explicitly:
# repro.rb
require 'tiny_tds'
class Hitchhiker
def execute
opts = { host: 'server.com', port: 1433, username: '***', password: '***' }
TinyTds::Client.new(opts).execute('SELECT 42 as answer_to_life')
end
end
dent = Hitchhiker.new
results = dent.execute
GC.start
puts results.to_a
$ for i in {1..20}; do ruby repro.rb 2>&1 | head -n 1; done
repro.rb:15:in `each': DBPROCESS is dead or not enabled (TinyTds::Error)
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15:in `each': DBPROCESS is dead or not enabled (TinyTds::Error)
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15:in `each': DBPROCESS is dead or not enabled (TinyTds::Error)
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15:in `each': DBPROCESS is dead or not enabled (TinyTds::Error)
repro.rb:15:in `each': DBPROCESS is dead or not enabled (TinyTds::Error)
repro.rb:15:in `each': DBPROCESS is dead or not enabled (TinyTds::Error)
repro.rb:15:in `each': DBPROCESS is dead or not enabled (TinyTds::Error)
repro.rb:15:in `each': DBPROCESS is dead or not enabled (TinyTds::Error)
repro.rb:15:in `each': DBPROCESS is dead or not enabled (TinyTds::Error)
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
repro.rb:15: [BUG] Segmentation fault at 0x0000000000000000
Thank you for your open source contribution and making this library available. Your work is appreciated!
Environment
Operating System
TinyTDS Version and Information
FreeTDS Version
Description
Reading
TinyTds::Results
tied to a connection that is closed results in a segmentation fault most of the time, instead of the expected exception.My expectation, is that the above code would raise a
TinyTds::Error
. When I run this multiple times, I see this happens rarely. The most common outcome is a Segmentation Fault:An example of the segmentation fault details:
For what it's worth, I can work around the issue by reading all of the results into ruby before closing the connection:
Please do let me know if I can provide more information or context.