[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] libevent 2.0.4: Segmentation fault with BEV_OPT_THREADSAFE set
- To: libevent-users <libevent-users@xxxxxxxxxxxxx>
- Subject: [Libevent-users] libevent 2.0.4: Segmentation fault with BEV_OPT_THREADSAFE set
- From: Jarod Liu <liuyuanzhi@xxxxxxxxx>
- Date: Fri, 2 Apr 2010 17:53:09 +0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Fri, 02 Apr 2010 05:53:16 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=Ggh4sQ/Fw/0F9icE8+SBgQO8j8g+DBvV4NBpG8pd0nU=; b=aV2XWEyHjBU4/IB1V/+gMPiTbdC+ZlD3+oNtDVT8sDbF1Vk35L3quifu7zTSpY/a05 dKbKyjCeAci53+AxGj1E0MSsdY3eR806Lh6QCVFEKCkpA3htQ3fAH0UNGTWMlMa8iVbX sm4XInBHe0xXdZJv7krpR9d/JbDbF8hN/o9l8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=LwnVGvkloor8Rch0nWhNsOctZqZ3GT8u0zZW7mJ4NMkTlwyeXjhZpFlAHNhbtya8Bi 5zj/RQ+ClwY3d7lhkeAENTN37/vdFmpjrE+r23ZNMhSV8CptZMnbLU88v/Q5/50hXT83 z8Rw7JuE2lFP4lCc4JPgSaTiQy2v5JQyZzAEs=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
My demo code works fine without the BEV_OPT_THREADSAFE option.
With the option segmentation fault 100% will happen.
Maybe it is a platform specified problem, I see no one report before.
=====================================================================
$ /usr/bin/c++ --version
c++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
$ lsb_release -a
LSB Version:
:core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5.4 (Final)
Release: 5.4
Codename: Final
=====================================================================
*** Aborted at 1270200692 (unix time) try "date -d @1270200692" if you
are using GNU date ***
PC: @ 0x17637a _bufferevent_incref_and_lock
*** SIGSEGV (@0x100) received by PID 32210 (TID 0xb7f8e6d0) from PID
256; stack trace: ***
@ 0x499440 (unknown)
@ 0x176d5c bufferevent_enable
@ 0x804901e accept_conn_cb()
@ 0x179d23 listener_read_cb
@ 0x16e5a9 event_base_loop
@ 0x16f1a5 event_base_dispatch
@ 0x8048f4d main
@ 0xa99e9c (unknown)
@ 0x8048b21 (unknown)
Segmentation fault
=====================================================================
#include <cstring>
#include <event2/util.h>
#include <event2/event.h>
#include <event2/bufferevent.h>
#include <event2/listener.h>
static void accept_conn_cb(struct evconnlistener* listener,
evutil_socket_t sockfd, struct sockaddr* addr, int socklen,
void *user_data) {
struct event_base *base = evconnlistener_get_base(listener);
struct bufferevent *bev = bufferevent_socket_new(
base, sockfd, BEV_OPT_CLOSE_ON_FREE |
BEV_OPT_THREADSAFE);
bufferevent_enable(bev, EV_READ | EV_WRITE);
for (char i='a'; i<'z'; i++) {
bufferevent_write(bev, &i, sizeof(i));
}
}
int main(int argc, char** argv) {
struct event_base *base;
struct sockaddr_in sin;
struct evconnlistener *listener;
base = event_base_new();
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(0);
sin.sin_port = htons(9050);
listener = evconnlistener_new_bind(base, accept_conn_cb, NULL,
LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, SOMAXCONN,
(struct sockaddr*)&sin, sizeof(sin));
event_base_dispatch(base);
return 0;
} // ---------- end of function main ----------
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.