From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thomas Klausner Newsgroups: gmane.lisp.guile.bugs Subject: bug#61957: NetBSD: JIT doesn't work Date: Sat, 4 Mar 2023 09:02:53 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31278"; mail-complaints-to="usenet@ciao.gmane.io" To: 61957@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Sat Mar 04 10:33:30 2023 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pYOGf-0007sP-HE for guile-bugs@m.gmane-mx.org; Sat, 04 Mar 2023 10:33:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pYOGK-00069D-5w; Sat, 04 Mar 2023 04:33:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYOGE-00067x-PU for bug-guile@gnu.org; Sat, 04 Mar 2023 04:33:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pYOGE-00020h-EP for bug-guile@gnu.org; Sat, 04 Mar 2023 04:33:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pYOGE-0003UH-7B for bug-guile@gnu.org; Sat, 04 Mar 2023 04:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Thomas Klausner Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 04 Mar 2023 09:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61957 X-GNU-PR-Package: guile X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167792233013345 (code B ref -1); Sat, 04 Mar 2023 09:33:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Mar 2023 09:32:10 +0000 Original-Received: from localhost ([127.0.0.1]:35256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYOFM-0003T8-O6 for submit@debbugs.gnu.org; Sat, 04 Mar 2023 04:32:10 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:37652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pYMrk-0001Cs-MB for submit@debbugs.gnu.org; Sat, 04 Mar 2023 03:03:41 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYMri-0004uW-PJ for bug-guile@gnu.org; Sat, 04 Mar 2023 03:03:40 -0500 Original-Received: from gatalith.at ([45.132.245.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pYMrd-0006op-Pb for bug-guile@gnu.org; Sat, 04 Mar 2023 03:03:37 -0500 Original-Received: from yt.nih.at (84-115-227-192.cable.dynamic.surfer.at [84.115.227.192]) by gatalith.at (Postfix) with ESMTPSA id 1AFCB390A44 for ; Sat, 4 Mar 2023 09:03:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gatalith.at; s=dkim; t=1677917005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=Z+mgFQRoF2eXfTT2SdorXQS8ZqS+Cld5Vz58f5CkBH0=; b=Zh+0Zkx7Mn7wjvqd1IKlwYQSnSAYe5swZQ+MdXc2CRRi4tPcB5w2CA56NJLehmKCsRbEpw Wzchw5JQlIQOa5r+SvkngxQsUDb1XA1DJ638YbaUuu2cCINbhRd+agS5f9wl0Ue8GW6Tui bKwriQeMVLXRwFYvp2TLy/Yiyt6XZOg= Content-Disposition: inline Received-SPF: pass client-ip=45.132.245.72; envelope-from=wiz@gatalith.at; helo=gatalith.at X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 04 Mar 2023 04:32:07 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.bugs:10561 Archived-At: Hi! guile 3.0.9 on NetBSD 10.99.2/amd64 defaults to enabling the JIT, butthen fails to build with: CCLD libguile-3.0.la ld: .libs/libguile_3.0_la-posix.o: in function `scm_tmpnam': /scratch/lang/guile30/work/guile-3.0.9/libguile/posix.c:1757: warning: warning: tmpnam() possibly used unsafely, use mkstemp() or mkdtemp() CCLD guile ld: ./.libs/libguile-3.0.so: warning: warning: tmpnam() possibly used unsafely, use mkstemp() or mkdtemp() GEN guile-procedures.texi allocating JIT code buffer failed: Permission denied jit.c:5896: fatal: assertion failed cat: stdout: Broken pipe [1] Done(1) cat alist.doc array-handle.doc array-map.doc a... | Abort trap (core dumped) GUILE_AUTO_COMPILE=0 ../meta/build-env guild s... gmake[3]: *** [Makefile:4657: guile-procedures.texi] Error 1 The underlying problem is that NetBSD by default has PaX MPROTECT enabled, i.e. a page can not be mapped executable and writable at the same time, which libguile/jit.c tries to do: ret->base = mmap (NULL, ret->size, PROT_EXEC | PROT_READ | PROT_WRITE, flags, -1, 0); On NetBSD (and some other systems) the workaround is to map the page twice - once writable, and once executable. The NetBSD mremap(2) man page describes this and has a complete code example: https://man.netbsd.org/mremap.2 Please add support for this to guile's JIT. Thank you! Thomas (Please note that there currently is a bug in NetBSD when using fork() in such a situation, see https://gnats.netbsd.org/55177 for details. A workaround is to map the page MAP_SHARED even though conceptually MAP_PRIVATE would be correct.)