Do you get SIGSEGV or SIGBUS? Because it might be an alignment issue.

I either case, what is your stack trace?

----- Original Message -----
From: "Alexey Ozeritsky" <aozerit...@gmail.com>
To: libevent-users@monkey.org
Sent: Friday, March 20, 2009 1:40:53 PM GMT +01:00 Amsterdam / Berlin / Bern / 
Rome / Stockholm / Vienna
Subject: [Libevent-users] libevent and arm

Hello,

A few months ago I discovered a problem with libevent and arm architecture.
I have TI DM355 board with montavista distribution, kernel
Linux testarm 2.6.10_mvl401 #8 Wed Mar 18 15:04:34 MSK 2009 armv5tejl unknown

My embedded libevent-based http server unexpectedly crashed. Then I
set variable EVENT_NOEPOLL=1 and everything went well.
The problem appears in the all libevent versions including the latest
1.4.9. Today I tried to discover the problem with gdb and made this
patch (attached):

Index: epoll.c
===================================================================
--- epoll.c     (revision 5589)
+++ epoll.c     (revision 5590)
@@ -141,7 +141,7 @@
        epollop->epfd = epfd;

        /* Initalize fields */
-       epollop->events = malloc(nfiles * sizeof(struct epoll_event));
+       epollop->events = calloc(nfiles, sizeof(struct epoll_event));
        if (epollop->events == NULL) {
                free(epollop);
                return (NULL);
@@ -226,6 +226,7 @@
                struct event *evread = NULL, *evwrite = NULL;

                evep = (struct evepoll *)events[i].data.ptr;
+               if (!evep) continue;

                if (what & (EPOLLHUP|EPOLLERR)) {
                        evread = evep->evread;

It works OK now, but I'm not sure I made a correct patch. And I don't
understand why it doesn't segfaulted on x86_64 or x86 architecture.

_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to