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

Re: [Libevent-users] How to reference event_base in other parts of code?



Hello Azat,

Thanks for you help.  out of scope usage was exactly the reason. Dynamically allocating the "g" struct fixes the issue.

On Thu, Mar 5, 2020 at 1:17 PM John Smith <johnsmith.gb.77@xxxxxxxxx> wrote:
You maybe right... I see now that the curl example only worked when it used event_base_dispatch() after memset'ing the static "GlobalInfo g "struct. So that struct was never removed as long as the program ran. In my case the struct is allocated on the stack and then i exit immediately leaving curl events/callbacks with invalid memory.

On Thu, Mar 5, 2020 at 12:55 PM Azat Khuzhin <azat@xxxxxxxxxxxx> wrote:
> After making this one change when I try to enter some url in the fifo my application segs fault.

Don't you have use-after-scope, in other words does your events created on heap?
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.