Date: Mon, 29 Sep 2003 21:23:15 +0200 From: vnebehaj@mail.ahiv.hu (Vilmos NEBEHAJ) To: freebsd-threads@freebsd.org Subject: Re: Threads Message-ID: <20030929192315.GB922@ahiv.hu> In-Reply-To: <000501c386aa$10fb1ac0$0100a8c0@stefan> References: <000501c386aa$10fb1ac0$0100a8c0@stefan>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Sep 29, 2003 at 07:52:27PM +0300, Stefan Chekanov wrote: > I am developing an application for FreeBSD that utilizes multiple threads. > It works fine, except that after some minutes of work most of the threads > suddenly stop. > > I have examined the stack and found that most of the threads have this stack > #0 ... in _thread_kern_sched() from /usr/lib/libc_r.so.4 > #1 ... in _thread_kern_sched_state() from /usr/lib/libc_r.so.4 > #2 ... in _thread_fd_lock_debug() from /usr/lib/libc_r.so.4 > #3 ... in _close() from /usr/lib/libc_r.so.4 > #4 ... in _res_close() from /usr/lib/libc_r.so.4 > #5 ... in res_send() from /usr/lib/libc_r.so.4 > #6 ... in res_query() from /usr/lib/libc_r.so.4 > #7 ... in res_querydomain() from /usr/lib/libc_r.so.4 > #8 ... in res_search() from /usr/lib/libc_r.so.4 > #9 ... in _gethostbydnsname() from /usr/lib/libc_r.so.4 > #10 ... in gethostbyname2() from /usr/lib/libc_r.so.4 > #11 ... in gethostbyname() from /usr/lib/libc_r.so.4 > > and one trhead with this stack > > #0 ... in _thread_sys_poll() from /usr/lib/libc_r.so.4 > #1 ... in _thread_kern_sched_state_unlock() from /usr/lib/libc_r.so.4 > #2 ... in _thread_kern_scheduler() from /usr/lib/libc_r.so.4 > #3 0x0 in ??() > > Does anybody have an idea what might cause threads to stop? > Is it possible that sockets library is not threads safe? > Especially the part that is used to resolve hostnames? gethostbyname() is not threadsafe, don't use it in threaded apps (or protect it with a mutex). -- [vili]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030929192315.GB922>