Uhm. Your event structure is a local variable that goes out of scope when the function returns. You are leaving libevent to work with garbage.
Niels. On 7/10/06, Pascal Hofstee <[EMAIL PROTECTED]> wrote:
Hi, On FreeBSD/i386 6.1-STABLE using libevent-1.2 (from ports) i noticed a consistent segmentation fault when trying to use evtimer_set from a different function context than event_dispatch(): Essentially i am doing the following: void myInit(void) { struct event timeout; struct timeval tv; evtimer_set(&timeout, watchdogFeed, &timeout); timerclear(&tv); tv.tv_sec = 1; event_add(&timeout, &tv); } int main(int argc, char **argv) { . . event_init(); myInit(); event_dispatch(); . . } When i execute the resulting binary i get a segmentation fault, with coredump: #0 0x28080a56 in event_tree_RB_MINMAX (head=0x5657e589, val=-1) at event.c:142 tmp = (struct event *) 0x5657e589 parent = (struct event *) 0x5657e589 #1 0x2808181a in timeout_next (base=0x804b000, tv=0xbfbfe9b0) at event.c:651 dflt = Unhandled dwarf expression opcode 0x93 (that dwarf expression opcode message is really odd there btw) If however i move the "event_dispatch()" call Into the context of my init() function ... everything suddenly behaves as expected. Can anybody else reproduce this and/or give me any hints on where i might possibly do something wrong ? -- Pascal Hofstee _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users
_______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users