Re: [gnet-devel] tcp socket reading segfault



On Wed, 2008-12-24 at 17:32 +0100, Hugo Calleja wrote:

> I am using gnet for a tcp socket server. The problem is that on
> freeing the data from a read event of one of the connections I get
> random segfaults.
> 
> The segfault comes from freeing the event -> buffer, because when I
> comment the line it doesnt segfault at all.

I think you shouldn't need to free this at all. According to the docs

http://library.gnome.org/devel/gnet/stable/gnet-conn.html#GConnEvent

the buffer is 'caller owned' (which means GNet, and not the callback),
so GNet will free it later. I don't think there's a way to take
ownership of the buffer and avoid memcpy()s.


> I tried gnet like a year ago and it did had the same problem. A guy in
> a chat (dont remember who) was helpful and told me that was a bug in
> gnet and I had to g_idle_add ( g_free, event -> buffer ). That worked
> then. I have tried it now, and it got better but at some point it
> segfaulted again.

The only big memleak I remember was in GConnHttp's steal_buffer(), I
find it hard to believe there's a leak in the code you're using, it
would have been very noticable, also I'd expect that it would have been
picked up by valgrind when running the unit tests.

Cheers
 -Tim




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]