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

Re: [Libevent-users] bufferevent_free() not safe within event callback in 2.0.2?



Hi Philip,

On Wed, Aug 17, 2016 at 02:19:08PM -0600, Philip Prindeville wrote:
> In the event handler, if I'm seeing a BUF_EVENT_TIMEOUT and I do a
> bufferevent_free() at that point, everything is fine.  But if during the
> same handler I try to do a bufferevent_free() for a BEV_EVENT_EOF then I see
> this:
> 
> [err] bufferevent.c:611: Assertion bufev_private->refcnt > 0 failed in _bufferevent_decref_and_unlock
> 
> Program received signal SIGABRT, Aborted.
> 0x00007ffff7614067 in __GI_raise (sig=sig@entry=6)
>     at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
> 56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.

Can you post full backstraces?
Also some trace from valgrind will be nice to have.

> 
> The example in the documentation here:
> 
> http://www.wangafu.net/~nickm/libevent-book/Ref6_bufferevent.html
> 
> says that doing a bufferevent_free() during a BEV_EVENT_EOF is safe, but
> that's not what I'm seeing.  Same thing happens if it's during a
> BEV_EVENT_ERROR, by the way.
> 
> My bufferevent was created with BEV_OPT_CLOSE_ON_FREE but I don't think that
> would make a difference.

This can be buggy if you use bufferevent inside bufferevent (like
filters or something like this), but I'm not sure that it is buggy, and
seems that you don't use this.

> Again, this is 2.0.2 so maybe the behavior changed in 2.1.1 for which I'm
> looking at documentation and examples.
> 
> The only bug I found in the changelog which might have anything to do with
> this is in 2.0.3:
> 
>  o Detect errors during bufferevent_connect().  Patch from Christopher
> Davis.
> 
> but it's not clear that's what I'm seeing... This was created as a
> bufferevent_socket_new().
> 
> And the EOF happens after the connect() succeeds, obviously.  The ERROR
> happens on an unconnected socket...

Can you try 2.1? Or it is not an option for you?
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.