Hi,
I am using libev as part of the Linux audit daemon. I have done some testing
with 3.53 recently and run across a couple of "issues".
I created a simple "hello world" program.
#include <stdio.h>
#include <sys/types.h>
#include <ev.h>
volatile int stop = 0;
static void term_handler(struct ev_loop *loop, struct ev_signal *sig,
int revents)
{
ev_unloop (ev_default_loop (EVFLAG_AUTO), EVUNLOOP_ALL);
stop = 1;
}
int main(void)
{
struct ev_loop *loop;
struct ev_signal sigterm_watcher;
loop = ev_default_loop (EVFLAG_NOENV);
ev_signal_init (&sigterm_watcher, term_handler, SIGTERM);
ev_signal_start (loop, &sigterm_watcher);
while (!stop)
ev_loop (loop, 0);
ev_loop_destroy(loop);
return 0;
}
When compiling, I get this:
In file included from test.c:3:
/home/sgrubb/working/BUILD/audit-1.8/src/libev/ev.h:123:5:
warning: "__STDC_VERSION__" is not defined
It would seem that line 123 of ev.h should be changed to:
#if defined( __STDC_VERSION__) && __STDC_VERSION__ >= 199901L || __GNUC__ >=
3
iow test to see if its defined before using it. But anyways, the real problem
shows up when you use valgrind against the test program. This is what
valgrind reports:
==10873== Memcheck, a memory error detector.
==10873== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==10873== Using LibVEX rev 1804, a library for dynamic binary translation.
==10873== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==10873== Using valgrind-3.3.0, a dynamic binary instrumentation framework.
==10873== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==10873== For more details, rerun with: -v
==10873==
==10873== Invalid free() / delete / delete[]
==10873== at 0x4A0609F: free (vg_replace_malloc.c:323)
==10873== by 0x40198C: ev_realloc_emul (ev.c:452)
==10873== by 0x40142C: main (test.c:27)
==10873== Address 0x6095c0 is not stack'd, malloc'd or (recently) free'd
==10873==
==10873== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 1)
==10873== malloc/free: in use at exit: 512 bytes in 1 blocks.
==10873== malloc/free: 6 allocs, 6 frees, 1,480 bytes allocated.
==10873== For counts of detected errors, rerun with: -v
==10873== searching for pointers to 1 not-freed blocks.
==10873== checked 69,656 bytes.
==10873==
==10873==
==10873== 512 bytes in 1 blocks are still reachable in loss record 1 of 1
==10873== at 0x4A0739E: malloc (vg_replace_malloc.c:207)
==10873== by 0x4A07527: realloc (vg_replace_malloc.c:429)
==10873== by 0x4033FF: array_realloc (ev.c:467)
==10873== by 0x405954: ev_signal_start (ev.c:2386)
==10873== by 0x405A20: ev_default_loop_init (ev.c:1679)
==10873== by 0x4013A4: ev_default_loop (ev.h:447)
==10873== by 0x4013CD: main (test.c:20)
==10873==
==10873== LEAK SUMMARY:
==10873== definitely lost: 0 bytes in 0 blocks.
==10873== possibly lost: 0 bytes in 0 blocks.
==10873== still reachable: 512 bytes in 1 blocks.
==10873== suppressed: 0 bytes in 0 blocks.
We are leaking memory and have an invalid free. Any ideas?
Thanks,
-Steve
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev