cotag / libuv

Ruby bindings for libuv
Other
60 stars 3 forks source link

Windows Segfault #1

Closed stakach closed 10 years ago

stakach commented 11 years ago

Segfaults when using any TCP functions

@luislavena you wouldn't have any ideas would you? Hoping to have this running across platforms

luislavena commented 11 years ago

Can you provide more details? Perhaps a back trace from gdb?

stakach commented 11 years ago

It doesn't really give much. I've been working at it for awhile and have come up wanting.

gdb:

Program received signal SIGSEGV, Segmentation fault.
0x0028e885 in ?? ()

Ruby:

-- C level backtrace information -------------------------------------------
C:\Windows\SysWOW64\ntdll.dll(ZwWaitForSingleObject+0x15) [0x77a7f8d1]
C:\Windows\syswow64\kernel32.dll(WaitForSingleObjectEx+0x43) [0x756b1194]
C:\Windows\syswow64\kernel32.dll(WaitForSingleObject+0x12) [0x756b1148]
c:\ruby\bin\msvcrt-ruby191.dll(rb_vm_bugreport+0xf9) [0x62e5c6d9]
c:\ruby\bin\msvcrt-ruby191.dll(rb_name_err_mesg_new+0x17a) [0x62d3a856]
c:\ruby\bin\msvcrt-ruby191.dll(rb_bug+0x2f) [0x62d3b533]
c:\ruby\bin\msvcrt-ruby191.dll(rb_check_safe_str+0x1a4) [0x62dee770]
 [0x004011e6]
C:\Windows\syswow64\kernel32.dll(GetProfileStringW+0x12aa3) [0x756f003f]
C:\Windows\SysWOW64\ntdll.dll(RtlKnownExceptionFilter+0xb7) [0x77ad74ff]

It's the most super unhelpful issue!

luislavena commented 11 years ago

Has libuv compiled with -g?

From the back trace, seems ruby is involved. Are you using a ruby extension that interfaces with libuv? What commit of libuv is using? I have the feeling some important information is missing from this report.

The more details you provide to help replicate this issue the better.

Thank you

luislavena commented 11 years ago

Sorry for missing some context information, but I see this is reported from a ruby gem and not libuv project itself.

From the tasks I see this is a ffi extension and the compilation is using visual Studio.

Please confirm both ruby and this gem are build with the same compiler and libuv had been built with debug symbols (-g) for gcc.

stakach commented 11 years ago

I'm compiling with vcbuild.bat shared release so ruby and libuv are built by different compilers (which shouldn't matter as libuv is a shared library) Tested using both the trunk build of libuv and the latest tagged stable Tested on your latest windows ruby releases 1.9 and 2.0 with the same results

The gem works on OSX and Linux without issue so I'm assuming the issue lies with ruby, the fii gem or libuv, on windows, the challenge is working out where...

stakach commented 11 years ago

Also it is only TCP that is failing. Possibly something to do with wrapping sockets in file descriptors? Although since libuv lies outside of ruby I am assuming it wouldn't be affected by that as it never exposes the underlying descriptors to ruby.

luislavena commented 11 years ago

@stakach this might be similar to the issue I've encountered before: https://github.com/charliesome/racer/pull/8#issuecomment-7583668

In that case, the possible issue could have been Ruby changing things like close, open, select and others, but I'm not sure.

To my bad, I couldn't find the time to explore this, specially since I don't have Visual Studio to build libuv (I would love to simply use MinGW)

stakach commented 11 years ago

hmm i see that was never resolved either.. damn.

I was inspired by racer to create https://github.com/cotag/spider-gazelle (work in progress) - runs rails apps and on all rubies. Serves assets slowly in development (no idea why) and has no logging output however does utilise all cores, unlike racer, so should be even faster.

Thanks for your help with this by the way!

stakach commented 11 years ago

No longer segfaults in the latest release of libuv! Wooo! Passing sockets over pipes on windows isn't working though, I opened an issue joyent/libuv#926

Soon spider-gazelle will be realized!

luislavena commented 11 years ago

AFAIK this is the same problem of nio4r with pipes that cannot be used with sockets (at least that was what nobu said, being a platform limitation).

If you can provide a C code that reproduces that with libuv I guess will get faster responses from libuv team.

stakach commented 11 years ago

Shouldn't be a platform limitation: http://memset.wordpress.com/2010/10/13/win32-api-passing-socket-with-ipc-method/ Libuv claims to support it too: http://nikhilm.github.io/uvbook/processes.html#sending-file-descriptors-over-pipes

I'll use their example c-code (updated to the latest version and see what happens)

luislavena commented 11 years ago

Interesting there is a warning there:

On Windows, only file descriptors representing TCP sockets can be passed around.

Pipes do not quality as tcp sockets so don't think can be passed around. But don't have experience with this.

luislavena commented 11 years ago

Link of reference: celluloid/nio4r#32

stakach commented 10 years ago

This is a joyent libuv issue. Closing for now.