From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27803 invoked by alias); 27 Nov 2013 05:29:30 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 27748 invoked by uid 48); 27 Nov 2013 05:29:27 -0000 From: "carlos at redhat dot com" To: glibc-bugs@sourceware.org Subject: [Bug network/10652] getaddrinfo causes segfault if multithreaded and linked statically Date: Wed, 27 Nov 2013 05:29:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: network X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: carlos at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg00294.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=10652 --- Comment #23 from Carlos O'Donell --- (In reply to Rich Felker from comment #22) > As long as libpthread is a separate DSO, avoiding loading it makes sense, > yes. However it seems that all the internal locking in glibc components > (including nss modules) could be done with lock functions available > unconditionally in libc rather than needing the pthread lock functions. I'm > not familiar enough with the glibc internals to know whether such functions > are already available, but it would certainly make for a cleaner solution to > this and many other problems if they are. Note that the locking requirements > for internal use are much simpler than pthread requirements; there are no > difficult issues like different mutex types, self-synchronized destruction, > etc. No, you make a good point, and internally glibc already uses just plain futexes for __libc_lock_lock, but for non-libc modules like libnss_files.so.2 (loaded as part of the NSS plugin mechanism) the __libc_lock_lock defines redirect to __pthread_mutex_lock. I see no reason at the moment why they couldn't just use futexes for serializing threaded access. There was certainly no futex support when these NSS modules were written so it might be a legacy issue. Switching them over to futex locking would solve this problem and the uncontended lock case is an atomic operation that should always succeeds. -- You are receiving this mail because: You are on the CC list for the bug.