-
Notifications
You must be signed in to change notification settings - Fork 188
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
Segementation Fault when reading from a closed connection #435
Comments
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
|
I know it's been a while - sorry for never responding to your issue. Many thanks for the detailed report and especially reproduction scripts. I can confirm this issue still exists, although I consistently get the error message:
I used Ruby v3.3.6. Fixing this scenario should be somewhat straight-forward, as we track internally whether the connection was closed or not. For the second scenario with the
My suspicion is that the GC sweeps something away it should not - likely some state associated with I'll take a detailed look at this someday. Having the reproduction scripts definitely helps to write tests for it. |
so I found the first bug and was able to fix it, see andyundso@2dd9313. the second one ... difficult. so, the There is two options: Once we were able to send the SQL query to the server, we give the ... or, we just stop lazy-loading data for |
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.
The text was updated successfully, but these errors were encountered: