You are not logged in.

#1 2024-05-21 08:45:03

chelas
Member
Registered: 2024-05-21
Posts: 4

[SOLVED] Cannot build any Go file: unexpected NUL in input in std libs

Currently on version 1.22.3. Issue persists even after reinstalling go. Right now I'm leaning towards the issue being a corrupted package, although I'm having trouble finding any actionable logs in that direction. Possibly be related to an unexpected power-off during an upgrade some months ago, but I believe I've taken care of everything that had to be done there and this is the only package acting out of the ordinary. I've searched the internet for solutions, but the only similar problems were caused by incorrect file encodings. Occurs even when trying to build the following code:

package main

import "fmt"

func main() {
	fmt.Println("Hello World")
}

The following errors come up:

main.go:3:8: read /usr/lib/go/src/fmt/doc.go: unexpected NUL in input
package command-line-arguments: read /usr/lib/go/src/runtime/abi_test.go: unexpected NUL in input

The same errors popup when trying to run anything more complex, just with more "unexpected NUL" in different std libs. I have checked the files mentioned and nothing appears to be out of the ordinary either

Can be reproduced quickly by running the following commands

mkdir hello && cd hello || exit
go mod init example/hello
cat > main.go << EOF
package main

import "fmt"

func main() {
	fmt.Println("Hello World")
}
EOF

# or alternatively running "go run ."
go build main.go

Here's the output of "go env". Should be unchanged from the default configuration (and is identical to the output of another working machine I have)

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/omar/.cache/go-build'
GOENV='/home/omar/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/omar/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/omar/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/omar/hello/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build398794559=/tmp/go-build -gno-record-gcc-switches'

Here is the output of

pacman -Qkk | grep -v '0 missed files' | grep -v '0 altered files'

. Although I'm guessing that I'd be noticing more serious problems if anything were wrong with these packages...

backup file: bluez: /etc/bluetooth/main.conf (Modification time mismatch)
backup file: bluez: /etc/bluetooth/main.conf (Size mismatch)
backup file: bluez: /etc/bluetooth/main.conf (SHA256 checksum mismatch)
backup file: filesystem: /etc/fstab (Modification time mismatch)
backup file: filesystem: /etc/fstab (Size mismatch)
backup file: filesystem: /etc/fstab (SHA256 checksum mismatch)
backup file: filesystem: /etc/group (Modification time mismatch)
backup file: filesystem: /etc/group (Size mismatch)
backup file: filesystem: /etc/group (SHA256 checksum mismatch)
backup file: filesystem: /etc/gshadow (Modification time mismatch)
backup file: filesystem: /etc/gshadow (Size mismatch)
backup file: filesystem: /etc/gshadow (SHA256 checksum mismatch)
backup file: filesystem: /etc/hosts (Modification time mismatch)
backup file: filesystem: /etc/hosts (Size mismatch)
backup file: filesystem: /etc/hosts (SHA256 checksum mismatch)
backup file: filesystem: /etc/passwd (Modification time mismatch)
backup file: filesystem: /etc/passwd (Size mismatch)
backup file: filesystem: /etc/passwd (SHA256 checksum mismatch)
backup file: filesystem: /etc/resolv.conf (Modification time mismatch)
backup file: filesystem: /etc/resolv.conf (Size mismatch)
backup file: filesystem: /etc/resolv.conf (SHA256 checksum mismatch)
backup file: filesystem: /etc/shadow (Modification time mismatch)
backup file: filesystem: /etc/shadow (Size mismatch)
backup file: filesystem: /etc/shadow (SHA256 checksum mismatch)
backup file: filesystem: /etc/shells (Modification time mismatch)
backup file: filesystem: /etc/shells (Size mismatch)
backup file: filesystem: /etc/shells (SHA256 checksum mismatch)
backup file: filesystem: /etc/subgid (Modification time mismatch)
backup file: filesystem: /etc/subgid (Size mismatch)
backup file: filesystem: /etc/subgid (SHA256 checksum mismatch)
backup file: filesystem: /etc/subuid (Modification time mismatch)
backup file: filesystem: /etc/subuid (Size mismatch)
backup file: filesystem: /etc/subuid (SHA256 checksum mismatch)
backup file: glibc: /etc/locale.gen (Modification time mismatch)
backup file: glibc: /etc/locale.gen (Size mismatch)
backup file: glibc: /etc/locale.gen (SHA256 checksum mismatch)
backup file: greetd: /etc/greetd/config.toml (Modification time mismatch)
backup file: greetd: /etc/greetd/config.toml (SHA256 checksum mismatch)
backup file: grub: /etc/default/grub (Modification time mismatch)
backup file: grub: /etc/default/grub (Size mismatch)
backup file: grub: /etc/default/grub (SHA256 checksum mismatch)
backup file: grub-btrfs: /etc/default/grub-btrfs/config (Modification time mismatch)
backup file: grub-btrfs: /etc/default/grub-btrfs/config (Size mismatch)
backup file: grub-btrfs: /etc/default/grub-btrfs/config (SHA256 checksum mismatch)
java-runtime-common: 21 total files, 2 altered files
libutempter: 20 total files, 1 altered file
backup file: ly: /etc/ly/config.ini (Modification time mismatch)
backup file: ly: /etc/ly/config.ini (Size mismatch)
backup file: ly: /etc/ly/config.ini (SHA256 checksum mismatch)
backup file: mkinitcpio: /etc/mkinitcpio.conf (Modification time mismatch)
backup file: mkinitcpio: /etc/mkinitcpio.conf (Size mismatch)
backup file: mkinitcpio: /etc/mkinitcpio.conf (SHA256 checksum mismatch)
ollama: 18 total files, 1 altered file
backup file: openssh: /etc/ssh/sshd_config (Modification time mismatch)
backup file: openssh: /etc/ssh/sshd_config (Size mismatch)
backup file: openssh: /etc/ssh/sshd_config (SHA256 checksum mismatch)
backup file: pacman: /etc/pacman.conf (Modification time mismatch)
backup file: pacman: /etc/pacman.conf (Size mismatch)
backup file: pacman: /etc/pacman.conf (SHA256 checksum mismatch)
backup file: pacman-mirrorlist: /etc/pacman.d/mirrorlist (Modification time mismatch)
backup file: pacman-mirrorlist: /etc/pacman.d/mirrorlist (Size mismatch)
backup file: pacman-mirrorlist: /etc/pacman.d/mirrorlist (SHA256 checksum mismatch)
backup file: pam: /etc/security/faillock.conf (Modification time mismatch)
backup file: pam: /etc/security/faillock.conf (Size mismatch)
backup file: pam: /etc/security/faillock.conf (SHA256 checksum mismatch)
shadow: 588 total files, 1 altered file
spotify: 156 total files, 6 altered files
backup file: sudo: /etc/sudoers (Modification time mismatch)
backup file: sudo: /etc/sudoers (Size mismatch)
backup file: sudo: /etc/sudoers (SHA256 checksum mismatch)
systemd: 1451 total files, 1 altered file
backup file: texlive-basic: /etc/texmf/web2c/fmtutil.cnf (Modification time mismatch)
backup file: texlive-basic: /etc/texmf/web2c/fmtutil.cnf (Size mismatch)
backup file: texlive-basic: /etc/texmf/web2c/fmtutil.cnf (SHA256 checksum mismatch)
backup file: ufw: /etc/ufw/ufw.conf (Modification time mismatch)
backup file: ufw: /etc/ufw/ufw.conf (Size mismatch)
backup file: ufw: /etc/ufw/ufw.conf (SHA256 checksum mismatch)
backup file: ufw: /etc/ufw/user.rules (Modification time mismatch)
backup file: ufw: /etc/ufw/user.rules (Size mismatch)
backup file: ufw: /etc/ufw/user.rules (SHA256 checksum mismatch)
backup file: ufw: /etc/ufw/user6.rules (Modification time mismatch)
backup file: ufw: /etc/ufw/user6.rules (Size mismatch)
backup file: ufw: /etc/ufw/user6.rules (SHA256 checksum mismatch)
backup file: util-linux: /etc/pam.d/su (Modification time mismatch)
backup file: util-linux: /etc/pam.d/su (Size mismatch)
backup file: util-linux: /etc/pam.d/su (SHA256 checksum mismatch)
backup file: util-linux: /etc/pam.d/su-l (Modification time mismatch)
backup file: util-linux: /etc/pam.d/su-l (Size mismatch)
backup file: util-linux: /etc/pam.d/su-l (SHA256 checksum mismatch)
vlc-luajit: 1080 total files, 1 altered file

Checking for broken symlinks with

find / -xtype l -print

doesn't yield anything relevant either. Some results pop up but they're all related to docker or flatpak (which I am not running Go under)

Apologies for the sparse information, but I'm at a complete loss on what the relevant logs would be

Last edited by chelas (2024-05-22 16:24:23)

Offline

#2 2024-05-21 14:38:03

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,989

Re: [SOLVED] Cannot build any Go file: unexpected NUL in input in std libs

file /usr/lib/go/src/fmt/doc.go
pacman -Qikk go

Offline

#3 2024-05-22 01:04:45

chelas
Member
Registered: 2024-05-21
Posts: 4

Re: [SOLVED] Cannot build any Go file: unexpected NUL in input in std libs

seth wrote:
file /usr/lib/go/src/fmt/doc.go
pacman -Qikk go

Here's the output

/usr/lib/go/src/fmt/doc.go: ASCII text
Name            : go
Version         : 2:1.22.3-1
Description     : Core compiler tools for the Go programming language
Architecture    : x86_64
URL             : https://golang.org/
Licenses        : BSD-3-Clause
Groups          : None
Provides        : go-pie
Depends On      : None
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : go-pie
Installed Size  : 209.54 MiB
Packager        : Lukas Fleischer <lfleischer@archlinux.org>
Build Date      : Tue 07 May 2024 09:15:43 PM MDT
Install Date    : Tue 21 May 2024 01:34:13 AM MDT
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

go: 14302 total files, 0 altered files

Offline

#4 2024-05-22 07:15:03

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,989

Re: [SOLVED] Cannot build any Go file: unexpected NUL in input in std libs

Package is fine, non-utf8 locale?

localectl
locale
locale -a

Offline

#5 2024-05-22 08:34:19

chelas
Member
Registered: 2024-05-21
Posts: 4

Re: [SOLVED] Cannot build any Go file: unexpected NUL in input in std libs

seth wrote:

Package is fine, non-utf8 locale?

localectl
locale
locale -a

Here's the output.

System Locale: LANG=en_US.UTF-8
    VC Keymap: (unset)
   X11 Layout: (unset)
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
C
C.utf8
en_US.utf8
POSIX

Also did a quick hexdump of all involved files to sanity check for a NUL character.
Interestingly it compiles and runs fine when using the gccgo compiler as provided by the gcc-go package

Offline

#6 2024-05-22 16:03:10

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,989

Re: [SOLVED] Cannot build any Go file: unexpected NUL in input in std libs

Have you  tried to

go clean -cache
go clean -testcache
go clean -fuzzcache
go clean -modecache

drop the caches?

Offline

#7 2024-05-22 16:23:31

chelas
Member
Registered: 2024-05-21
Posts: 4

Re: [SOLVED] Cannot build any Go file: unexpected NUL in input in std libs

Ouch, could've sworn that I did but when I checked I missed the "-cache" flag.
That did it! Thank you very much for your help

Offline

Board footer

Powered by FluxBB