richardhundt / luv

libuv bindings for Lua
Apache License 2.0
118 stars 19 forks source link

Segfault on tcp connect to tcp_echosvr.lua #6

Closed losinggeneration closed 11 years ago

losinggeneration commented 11 years ago

This code causes a segfault on cleanup:

local luv = require('luv')
luv.net.tcp():connect('127.0.0.1', 8080)

OS: Arch Linux 64 bit Lua: 5.1.5 git head: e48f475e8d98efafcf39b17e059d3dac98b1fa5e

Let me know if you need more info to reproduce the crash.

-- update to indicate that it's not on connect, but rather on cleanup

richardhundt commented 11 years ago

Hi, thanks for the report.

I can't repro on Ubuntu 12.04 x86_64. It may be a GC race as you have don't have the tcp socket object anchored (no local variable).

Could you change line 27 of ./src/luv.h from

undef LUV_DEBUG

to

define LUV_DEBUG

and recompile.

It's pretty noisy, but it'd be great if you could send me the output from the client code and I'll take a look

Thanks! Richard

On Oct 8, 2012, at 11:54 PM, Harley Laue wrote:

local luv = require('luv') luv.net.tcp():connect('127.0.0.1', 8080)

losinggeneration commented 11 years ago

lua tcp_echoclient.lua luv_thread.c: 26: luvL_thread_suspend: loop top luv_thread.c: 5: luvL_thread_ready: SET READY luv_thread.c: 29: luvL_thread_suspend: uv_run_once returned, active: 0 luv_thread.c: 31: luvL_thread_suspend: main ready, breaking luv_thread.c: 36: luvL_thread_suspend: back in main luv_object.c: 23: luvL_object_close: object closing 0x926828, type: 12 luv_stream.c: 277: luvL_stream_free: free stream: 0x926828 luv_object.c: 23: luvL_object_close: object closing 0x923868, type: 7 zsh: segmentation fault lua tcp_echoclient.lua

richardhundt commented 11 years ago

This was a bug in libuv - git HEAD is now fixed.

On Oct 9, 2012, at 1:59 AM, Harley Laue wrote:

lua tcp_echoclient.lua luv_thread.c: 26: luvL_thread_suspend: loop top luv_thread.c: 5: luvL_thread_ready: SET READY luv_thread.c: 29: luvL_thread_suspend: uv_run_once returned, active: 0 luv_thread.c: 31: luvL_thread_suspend: main ready, breaking luv_thread.c: 36: luvL_thread_suspend: back in main luv_object.c: 23: luvL_object_close: object closing 0x926828, type: 12 luv_stream.c: 277: luvL_stream_free: free stream: 0x926828 luv_object.c: 23: luvL_object_close: object closing 0x923868, type: 7 zsh: segmentation fault lua tcp_echoclient.lua

— Reply to this email directly or view it on GitHub.