unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Thomas Klausner <wiz@gatalith.at>
To: 61957@debbugs.gnu.org
Subject: bug#61957: NetBSD: JIT doesn't work
Date: Sat, 4 Mar 2023 09:02:53 +0100	[thread overview]
Message-ID: <ZAL7LXjYAjTmYXKv@yt.nih.at> (raw)

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.)





                 reply	other threads:[~2023-03-04  8:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZAL7LXjYAjTmYXKv@yt.nih.at \
    --to=wiz@gatalith.at \
    --cc=61957@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).