Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Segmentation fault #20

Closed
agarbutt opened this Issue Oct 25, 2012 · 13 comments

Comments

Projects
None yet
3 participants

I have a segmentation fault occurring with BLOB columns and many reads. I am having a hard time diagnosing the issue. It seems to me that I may be hitting a threading bug or something. Any assistance in helping me identify the issue would be greatly appreciated.

https://gist.github.com/3955450

ruby 1.9.3p194 [x86_64-linux]
rails 3.2.8
activerecord-oracle_enhanced-adapter 1.4.1
ruby-oci8 2.1.2

Owner

kubo commented Oct 26, 2012

Thank you for the dump. I reproduced the issue by the following code.
Commenting out OCILobFreeTemporary in lob.c dismisses the issue but it
will cause resource leak. It may be difficult to fix the issue.

require 'oci8'
conn = OCI8.new('ruby/oci8@//localhost/XE')

blob1 = OCI8::BLOB.new(conn, ' '  * (1024 * 1024))
blob2 = OCI8::BLOB.new(conn, ' '  * (128 * 1024 * 1024))

thr = Thread.new do
  loop do
    blob2.rewind
    blob2.read
  end
end

sleep 1
blob1 = nil  # blob1's value will be freed in GC.
sleep 10

thr.kill
conn.logoff
Owner

kubo commented Oct 26, 2012

I made a patch for 2.1.2.
Download fix-issue-20.dif at https://gist.github.com/3956611

tar xvfz ruby-oci8-2.1.2.tar.gz
cd ruby-oci8-2.1.2
patch -p1 <  change-this-path/fix-issue-20.dif

Change the version number in the file ruby-oci8-2.1.2/VERSION to 2.1.2.1

gem build ruby-oci8.gemspec 

So this patch does, indeed, suppress the seg fault. Thank you for the quick turn around. This patch seems like it could still leak memory on the server, is that correct? Let me know when you have this merged and published as a gem. Id like to deploy this and collect some more information given the additional error handling.

Owner

kubo commented Oct 28, 2012

I made a patch again.
Download fix-issue-20-2.dif at https://gist.github.com/3967362

tar xvfz ruby-oci8-2.1.2.tar.gz
cd ruby-oci8-2.1.2
patch -p1 <  change-this-path/fix-issue-20-2.dif
gem build ruby-oci8.gemspec 
Owner

kubo commented Oct 28, 2012

I'll release 2.1.3 next week or after next.

@kubo kubo added a commit that referenced this issue Oct 28, 2012

@kubo kubo Fix SEGV when a temporary LOB is GCed while another LOB is read.
(github issue #20 reported by techsplicer)
2cbe227

Thank you again for the quick turn around. Ill test this branch under some load and report back.

agarbutt commented Nov 5, 2012

So far, i have not had any issues in my test environment. However, its load is not nearly enough to test at this point. I am comfortable with this patch and waiting for the next release. If we need to re-address this, I will follow up at that point.

Owner

kubo commented Dec 16, 2012

Close the issue.
If you get same problem again, create a new issue.

@kubo kubo closed this Dec 16, 2012

I'm still seeing segfaults with 2.1.3. I haven't found a way yet to reproduce it. Any ideas?

https://gist.github.com/583d137ab6b6ca734fab

Should I open a new ticket for this?

Owner

kubo commented Dec 18, 2012

It looks same issue.
I'll reopen this.

@kubo kubo reopened this Dec 18, 2012

@kubo kubo added a commit that referenced this issue Dec 23, 2012

@kubo kubo Fix SEGV when a temporary LOB is freed when OCILobRead returns OCI_NE…
…ED_DATA.

(github issue #20 reported by Edgars Beigarts)
719ea6f
Owner

kubo commented Dec 23, 2012

I have fixed SEGV generated by the following code.

require 'oci8'
conn = OCI8.new('ruby/oci8@//localhost/XE')

blob1 = OCI8::BLOB.new(conn, ' '  * (1024 * 1024))
blob2 = OCI8::BLOB.new(conn, ' '  * (128 * 1024 * 1024))

blob1 = nil  # blob1's value will be freed in GC.
blob2.read

conn.logoff

Ebeigarts, could you try 719ea6f?

Thanks @kubo will try that.

Owner

kubo commented Jan 4, 2013

I'll close this issue. If you get same errors, let me know.
The next version will be released this weekend.

@kubo kubo closed this Jan 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment