zenchild / gssapi

A Ruby FFI wrapper around GSSAPI
Other
40 stars 50 forks source link

Segmentation Fault #12

Closed cbeer closed 3 years ago

cbeer commented 12 years ago

Hi,

I'm trying to use gssapi on: Darwin m3dl-sm-04-mbpt 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

When I run the specs, I see this segfault (across multiple versions of ruby). Any hints for tracking this down?

Thanks, Chris

WARNING: Could not load IOV methods. Check your GSSAPI C library for an update WARNING: Could not load AEAD methods. Check your GSSAPI C library for an update ..

Finished in 0.01241 seconds 2 examples, 0 failures /Volumes/TempStorage/Projects/gssapi/lib/gssapi/lib_gssapi.rb:182: [BUG] Segmentation fault ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin12.2.0]

-- Control frame information ----------------------------------------------- c:0007 p:---- s:0028 b:0028 l:000027 d:000027 CFUNC :gss_delete_sec_context c:0006 p:0051 s:0022 b:0022 l:000021 d:000021 METHOD /Volumes/TempStorage/Projects/gssapi/lib/gssapi/lib_gssapi.rb:182 c:0005 p:0097 s:0016 b:0016 l:000015 d:000015 METHOD /Volumes/TempStorage/Projects/gssapi/lib/gssapi/lib_gssapi.rb:165 c:0004 p:0015 s:0012 b:0012 l:000011 d:000011 METHOD /Users/cabeer/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/ffi-1.1.5/lib/ffi/autopointer.rb:146 c:0003 p:0026 s:0008 b:0008 l:000007 d:000007 METHOD /Users/cabeer/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/ffi-1.1.5/lib/ffi/autopointer.rb:133 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:001728 d:001728 TOP

-- Ruby level backtrace information ---------------------------------------- /Users/cabeer/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/ffi-1.1.5/lib/ffi/autopointer.rb:133:in call' /Users/cabeer/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/ffi-1.1.5/lib/ffi/autopointer.rb:146:inrelease' /Volumes/TempStorage/Projects/gssapi/lib/gssapi/lib_gssapi.rb:165:in release' /Volumes/TempStorage/Projects/gssapi/lib/gssapi/lib_gssapi.rb:182:inrelease_ptr' /Volumes/TempStorage/Projects/gssapi/lib/gssapi/lib_gssapi.rb:182:in `gss_delete_sec_context'

-- C level backtrace information -------------------------------------------

See Crash Report log file under ~/Library/Logs/CrashReporter or /Library/Logs/CrashReporter, for the more detail of.

-- Other runtime information -----------------------------------------------

[NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html

Abort trap: 6

stensonb commented 11 years ago

Anybody working on this?

zenchild commented 11 years ago

@stensonb not that I know. I do not have a Mac environment to test on so unless someone can submit a patch it remains as-is.

pmorton commented 11 years ago

Seems to repro with the builtin version of heimdal. If you compile MIT kerberos and use that the lib works fine. I wonder if there is a difference in some struct somewhere.

pmorton commented 11 years ago

Is it possible that this could be a simular issue?

https://github.com/zenchild/gssapi/issues/3

pmorton commented 11 years ago

More info here. Looks like it might be heimdal's fault. http://www.stacken.kth.se/lists/heimdal-discuss/2000-01/msg00006.html

pmorton commented 11 years ago

@zenchild I really cannot seem to track this down. This is prevent the winrm gem from working properly on OSX. How would you feel about detecting heimdal on OSX and only leaking the pointer then? Other approaches are to use something like https://github.com/tenderlove/neversaydie to catch the segfault on free.

nicoolas25 commented 11 years ago

I have a segmentation fault too on a Windows server.

I've a Rails application with a SSO module based on gssapi. The authentication code looks like the gss_server.rb example.

When a first user authenticate himself, it works fine. If I try to authenticate a second one, then Ruby crashes with:

<my gssapi source path>/lib/gssapi/simple.rb:190: [BUG] Segmentation fault
tcs-ruby 1.9.3p231 (2012-05-25, TCS patched 2012-05-27) [i386-mingw32]

-- Control frame information -----------------------------------------------
c:0097 p:---- s:0505 b:0505 l:000504 d:000504 CFUNC  :gss_acquire_cred

<1600 lines of debug informations>

The same code works fine on an Debian server.

I post this here because the leak-the-pointer workaround proposed by @cbeer worked... It could be related and I hope it will help @zenchild to fix this.

jthuau commented 11 years ago

Have a look at the patch I just submitted in issue #16

pmorton commented 11 years ago

@jthuau I still get a sevfault with your branch....

https://gist.github.com/6178439

mac2000 commented 10 years ago

I was trying figure out why vagrant can not communicate with windows via winrm

Then I get to winrm gem, and try figure out why and how it can communicate via kerberos

But while trying run samples, I got Segmentation fault error

As I understand it is gsapi issue rather that winrm, can I help somehow test this issue so it will be fixed somewhere in the future?

I am trying to run it on Windows 8.1, MIT Kerberos 4.0.1, Ruby 1.9.3

zenchild commented 10 years ago

Just pulled in the patch from @jthuau.

senny commented 8 years ago

I'm using gssapi (1.2.0) and I'm getting this error. (On a OS-X El Capitan)

-- Control frame information -----------------------------------------------
c:0151 p:---- s:0826 e:000825 CFUNC  :gss_delete_sec_context
c:0150 p:0043 s:0820 e:000819 METHOD /Users/senny/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gssapi-1.2.0/lib/gssapi/lib_gssapi.rb:182
c:0149 p:0072 s:0814 e:000813 METHOD /Users/senny/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gssapi-1.2.0/lib/gssapi/lib_gssapi.rb:165
c:0148 p:0011 s:0810 e:000809 METHOD /Users/senny/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/ffi-1.9.10/lib/ffi/autopointer.rb:157
c:0147 p:0020 s:0806 e:000805 METHOD /Users/senny/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/ffi-1.9.10/lib/ffi/autopointer.rb:144 [FINISH]
c:0146 p:0020 s:0802 e:000801 METHOD /Users/senny/.rbenv/versions/2.2.3/lib/ruby/2.2.0/set.rb:291
c:0145 p:0009 s:0798 e:000797 BLOCK  /Users/senny/.rbenv/versions/2.2.3/lib/ruby/2.2.0/set.rb:375 [FINISH]
c:0144 p:---- s:0795 e:000794 IFUNC
c:0143 p:---- s:0793 e:000792 CFUNC  :each
c:0142 p:---- s:0791 e:000790 CFUNC  :each_entry
c:0141 p:0024 s:0788 e:000787 METHOD /Users/senny/.rbenv/versions/2.2.3/lib/ruby/2.2.0/set.rb:94
c:0140 p:0036 s:0783 E:001868 METHOD /Users/senny/.rbenv/versions/2.2.3/lib/ruby/2.2.0/set.rb:375
c:0139 p:0071 s:0779 e:000778 METHOD /Users/senny/.rbenv/versions/2.2.3/lib/ruby/2.2.0/set.rb:88 [FINISH]
c:0138 p:---- s:0774 e:000773 CFUNC  :new

Is there anything I can do except to comment out that line?

colinmarc commented 8 years ago

@zenchild any chance we could get a version bump for this fix?

jnardone commented 6 years ago

Why is this issue closed? This is still a valid issue. Can we get this PR'd into this repo and released? cc; @zenchild

abohne commented 6 years ago

Is this ever getting fixed?

timami commented 5 years ago

Why was this issue closed without any clarification. This method still seg faults.

lukas-kairevicius commented 4 years ago

The method still segaults. Any possibility of a fix?

zenchild commented 3 years ago

Sorry I've let this linger for so long. I used to have access to lots of KDCs so I always had places to test. Now I don't really have access to one anymore and setting one up hasn't been a priority for me :) However, I spent some time configuring a Docker setup tonight so I can dig into this a bit more. Assuming you are using the GSSAPI::Simple interface, would someone be able to capture the token passed to the init_context method? I have a hunch that this is malformed or empty but before I add a fix for this I want to be certain. Many thanks.

zenchild commented 3 years ago

Would anyone be able to test the bugfix/issue-12_segfault-on-gss_delete_sec_context branch to see if this fixes the problem? I was able to solve it for two instances I have set up in a test environment but it isn't close to a real-world KDC implementation. I tested with OSX and Linux, both Heimdal and MIT so I have most of my bases covered but there's lots of config options that come into play with Kerberos. Thanks everyone!

zenchild commented 3 years ago

This should now be fixed in version 1.3.1