From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5714 Path: news.gmane.org!not-for-mail From: Isaac Dunham Newsgroups: gmane.linux.lib.musl.general Subject: openmp/pthreads and fork... Date: Mon, 4 Aug 2014 22:56:51 -0700 Message-ID: <20140805055650.GA2108@newbook> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1407218234 11557 80.91.229.3 (5 Aug 2014 05:57:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Aug 2014 05:57:14 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5719-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 05 07:57:10 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XEXkD-0002FN-LM for gllmg-musl@plane.gmane.org; Tue, 05 Aug 2014 07:57:09 +0200 Original-Received: (qmail 15552 invoked by uid 550); 5 Aug 2014 05:57:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 15543 invoked from network); 5 Aug 2014 05:57:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=cVpQeXwteivTpZsWu3vqrtG1m6noeUmU9ZdVQ8GFMX0=; b=i/vXnIc17xGu2RrNYqeNZ7BlXH7cxG4pec/qtrsqb7BQaqUhjSH8qkPXreF9lTFyl2 svIDiuo3KePEe6RzvLU1tZ5j5GnQrLPIkFMQmn5SaES40gV0W7recqw4VzEh/Fv94vMq u7gsPBHKuO6Wd3PoFJmhCZkvLrIFx6GgtnfNcJG7Vf3QOpH8Uulht7UFR3V9pr8VnwHq ap2+7iCYmtyBhUzjEVyYwrhWg8LT8IF0HNdwx/1G/HNaneY++2Bx4TCTBFVXejQphzgu KMjHHjIbUSnw5V1THcdCfJu6G5a8TJ3/QpAzmtim7S5c4IzSO/I3ZbJ9gcx9Pimicp5g qtKA== X-Received: by 10.68.191.194 with SMTP id ha2mr1537657pbc.143.1407218216447; Mon, 04 Aug 2014 22:56:56 -0700 (PDT) Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:5714 Archived-At: Hello, I've been packaging OpenBLAS for Alpine Linux, and an issue came to my attention: OpenBLAS (optionally) uses pthreads or OpenMP, and OpenMP uses pthreads. OpenBLAS implements the BLAS (Basic Linear Algebra Subprograms) API/ABI, like ATLAS, MKL, and so on. Some programs that use BLAS will fork(); python is one of these. With OpenBLAS, this had caused "random" segfaults due to use of threads by the library both before and after the fork. The OpenBLAS issue is here: https://github.com/xianyi/OpenBLAS/issues/294 They worked around this using pthread_atfork() to cleanup before the fork(). I see some claims that calling any pthread functions in the child would be UB, so I'm wondering about a few things: -Is the last-mentioned claim correct? -What is musl's behavior? -How correct, and how likely to work with musl, is the fix for libgomp mentioned here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60035 (and for that matter, the equivalent workaround referred to in OpenBLAS issue 294)? -Is there a safe (non-crashing) way to use/write libraries that might or might not be built with threading--whether POSIX-specified or just "working with musl" ? Thanks, Isaac Dunham PS: OpenBLAS almost built out of the box; the only issue was use of get_nprocs(), a GNU extension equivalent to sysconf(_SC_NPROCESSORS_ONLN). When I submitted a patch, it was merged in about 2 hours. I've been building with NO_AFFINITY=1 ... TARGET=ATOM.