NetBSD Problem Report #59620

From www@netbsd.org  Sun Aug 31 07:21:20 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 3359F1A923A
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 31 Aug 2025 07:21:20 +0000 (UTC)
Message-Id: <20250831072119.0B4221A923E@mollari.NetBSD.org>
Date: Sun, 31 Aug 2025 07:21:19 +0000 (UTC)
From: tallirishllama@gmail.com
Reply-To: tallirishllama@gmail.com
To: gnats-bugs@NetBSD.org
Subject: lang/go14 fails to build on FreeBSD with ASLR
X-Send-Pr-Version: www-1.0

>Number:         59620
>Category:       pkg
>Synopsis:       lang/go14 fails to build on FreeBSD with ASLR
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bsiegert
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 31 07:25:00 +0000 2025
>Last-Modified:  Sun Aug 31 07:55:58 +0000 2025
>Originator:     Sean Hickey
>Release:        pkgsrc-2025Q2 2025-08-30
>Organization:
>Environment:
FreeBSD xxx 14.3-RELEASE FreeBSD 14.3-RELEASE-p2 GENERIC amd64

>Description:
The package lang/go14 used for bootstrapping Go fails to build on FreeBSD with ASLR enabled. I've been successfully using a patch for this that I found on the FreeBSD bugzilla, so it would be nice to include this fix in pkgsrc too.

Here is a link to the buzilla comment with the patch:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235735#c11


For reference, the actual error it throws is the following:

runtime: address space conflict: map(0xc208000000) = 0xc208102000
fatal error: runtime: address space conflict                                                   

runtime stack:
runtime.throw(0x7e5006)
        pkg/go14/src/runtime/panic.go:491 +0xad fp=0x820e51a18 sp=0x820e519e8
runtime.SysMap(0xc208000000, 0x100000, 0x0, 0x802818)
        pkg/go14/src/runtime/mem_freebsd.c:90 +0xd3 fp=0x820e51a50 sp=0x820e51a18
>How-To-Repeat:
Install FreeBSD with ASLR enabled (one of the additional security options in the installer). Then bootstrap pkgsrc and attempt to build lang/go14 from pkgsrc.
>Fix:
Add a new patch file for lang/go14 to fix src/runtime/mem_freebsd.c.

I'll include the full patch file I've been using below:

patch-src_runtime_mem__freebsd.c


$NetBSD$

Fix FreeBSD address space conflict when ASLR is enabled.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235735

--- src/runtime/mem_freebsd.c.orig      2015-09-23 04:37:37.000000000 +0000
+++ src/runtime/mem_freebsd.c
@@ -73,6 +73,11 @@ runtime·SysReserve(void *v, uintptr n,
        return p;
 }

+enum
+{
+       MAP_EXCL = 0x4000
+};
+
 void
 runtime·SysMap(void *v, uintptr n, bool reserved, uint64 *stat)
 {
@@ -82,7 +87,7 @@ runtime·SysMap(void *v, uintptr n, bool

        // On 64-bit, we don't actually have v reserved, so tread carefully.
        if(!reserved) {
-               p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
+               p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_EXCL|MAP_PRIVATE, -1, 0);
                if(p == (void*)ENOMEM)
                        runtime·throw("runtime: out of memory");
                if(p != v) {

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->bsiegert
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Sun, 31 Aug 2025 07:55:58 +0000
Responsible-Changed-Why:
Over to the go-master


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.