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

[Libevent-users] Event timeout after it has been freed



Hey,
I'm still investigating the issues from my other email and came across another thing. This might, again, be due to memory corruption on my side - I'm hoping it isn't though.

I implemented a simple timer-event class which basically creates an event with a timeout and calls an std::function once that timeout is hit.
Every now and then I get crashes in my ping event.
The ping event is a lambda which captures the "this" pointer of my socket and just pings the client every 30 seconds. The crashes are always related to the ping event having a nullptr as the socket pointer. So I did some recording in gdb and came to the conclusion it gets set to 0 in the destructor of the event class, which gets called when a socket disconnects.
Backtrace can be seen here:
http://puu.sh/9KSs8/927aa257e2.txt
Destructor just calls event_del, if the event is running, followed by an event_free It rarely happens, I had to wait for that crash for about 5hours, thats 10k connections minimum.

Could it be the event doesnt get canceled when it is pending?
Like the event "queue" could look something like this
1. Disconnect socket x
2. Socket y recieve
4. Socket x send
5. Event z timeout

"1." would cancel Event z though
(I am just guessing here since I have no idea why it's happening)

Really hope someone is able to help me out, slowly going insane..

imer

***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.