pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg/57158: Erlang 25.2 fails to build in default pkg_comp sandbox that does not mount /var/shm
>Number: 57158
>Category: pkg
>Synopsis: Erlang 25.2 fails to build in default pkg_comp sandbox that does not mount /var/shm
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jan 04 10:55:01 +0000 2023
>Originator: Michael Taylor
>Release: NetBSD 9.2, pkgsrc HEAD 2023-01-04
>Organization:
>Environment:
NetBSD lenovo.home.lan 9.2 NetBSD 9.2 (GENERIC) #0: Wed May 11 16:53:21 AEST 2022 met%lenovo.home.lan@localhost:/usr/src/sys/arch/amd64/compile/obj/GENERIC amd64
>Description:
Erlang 24 introduced a JIT-compiler and uses that compiler during it's build process. The JIT-compiler implementation on NetBSD uses shm_open [1] & [2].
For erlang to build it needs a working shm_open setup, namely a correctly mounted /var/shm mount. This condition is not met by default in the sandbox used by pkg_comp [3].
A problem report is being submitted here rather than just with pkg_comp since this may affect other packages using shm_open during their build, and in other chroot based build systems. I assume this is the reason why the most recent binary packages [4] are all pre Erlang 24, because the build server is using a chroot based build system with /var/shm not mounted.
I am not sure where any fix/changes should be made but I will start with raising an issue with pkg_comp [5] to make /var/shm mounting an option rather than a custom hook.
[1] https://man.netbsd.org/NetBSD-9.2/shm_open.3
[2] https://github.com/erlang/otp/blob/OTP-25.2/erts/emulator/asmjit/core/virtmem.cpp#L353
[3] https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_comp/index.html
[4] https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/erlang/index.html
[5] https://github.com/jmmv/pkg_comp/
>How-To-Repeat:
Build the lang/erlang (25.2) package inside a chroot that does not have /var/shm mounted. In my case that was running:
# pkg_comp auto erlang
The ERLC steps will fail with the following error
---
beam/jit/beam_jit_main.cpp:177:pick_allocator(): Internal error: jit: Cannot allocate executable memory. Use the interpreter instead.
---
The core error is shm_open returning errno ENOTSUP since /var/shm is not mounted.
I used the following test to check when shm_open was working inside my chroot (linked with -lrt):
---
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
void main(void) {
if (shm_open("/shm-test", O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR) >= 0) {
printf("OK\n");
} else {
printf("ERROR %s\n", strerror(errno));
}
}
---
>Fix:
I have successfully built erlang-25.2 with pkg_comp by mounting /var/shm inside pkg_comp's pkg_comp_post_mount_hook.
My complete sandbox.conf is now:
---
SANDBOX_TYPE=netbsd-release
SANDBOX_ROOT=/var/pkg_comp/sandbox
NETBSD_RELEASE_RELEASEDIR="/usr/obj/releasedir/amd64"
pkg_comp_post_mount_hook() {
mount -t tmpfs -o rw -o -m1777 -o -sram%10 tmpfs /var/pkg_comp/sandbox/var/shm
true
}
---
Home |
Main Index |
Thread Index |
Old Index