shenwei356/brename

Segmentation Fault upon execution in OpenBSD 6.9

Closed this issue · 3 comments

Obviously, this is an extremely handy script that I have enjoyed using for years. Unfortunately, I have not used it lately. So, when I got back around to using it, I updated to the newest release and attempted a dry run:

brename -p "\.php" -r "\.jpg" -d
[1]    35399 segmentation fault  /home/user/go/bin/brename -p "\.php" -r ".jpg" -d

Then I tried to see what could have caused the issue and how to enable verbose output by accessing help:

brename --help                  
[1]    84355 segmentation fault  /home/user/go/bin/brename --help

brename -h                  
[1]    84355 segmentation fault  /home/user/go/bin/brename -h

Even if I just enter the command brename the result is 31825 segmentation fault. Not sure how to best approach troubleshooting this further. Let me know what else I can do or what other information I can provide to best assist in resolving this bug.

I am currently running OpenBSD 6.9 with go version go1.16.6 openbsd/amd64 in zsh 5.8 (x86_64-unknown-openbsd6.9)

Still produces segmentation fault upon execution in OpenBSD 7.2.

Should it be assumed OpenBSD will not be supported?

How about compiling from the source?


wget https://go.dev/dl/go1.17.12.linux-amd64.tar.gz

tar -zxf go1.17.12.linux-amd64.tar.gz -C $HOME/

# or 
#   echo "export PATH=$PATH:$HOME/go/bin" >> ~/.bashrc
#   source ~/.bashrc
export PATH=$PATH:$HOME/go/bin

git clone https://github.com/shenwei356/brename
cd brename
go build

# or for statically-linked binary:
CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 go build -tags netgo -ldflags '-w -s'

The release note of go1.17 mentioned:

OpenBSD
The 64-bit MIPS architecture on OpenBSD (the openbsd/mips64 port) now supports cgo.

In Go 1.16, on the 64-bit x86 and 64-bit ARM architectures on OpenBSD (the openbsd/amd64 and openbsd/arm64 ports) system calls are made through libc, instead of directly using machine instructions. In Go 1.17, this is also done on the 32-bit x86 and 32-bit ARM architectures on OpenBSD (the openbsd/386 and openbsd/arm ports). This ensures compatibility with OpenBSD 6.9 onwards, which require system calls to be made through libc for non-static Go binaries.

And go1.18 and go1.19 did not mention the compatibility of OpenBSD. I'm not sure if it's related to Go version.

Here's a binary for openbsd/amd64 (go1.19rc2): brename.tar.gz

Or, you could provide a totally awesome response... that works too... :)

It worked like I remembered it! And, I discovered the reason for the difficulty. I am Embarassed to admit it, but I had a really old version aliased in my shell rc file to an obscure folder. I never saw it, had forgotten, and never would have realized it was there.

This is so super awesome!

Bulk renaming of files is a task every admin has to perform, yet in my experience, tools to accomplish this task easily are limited. Your tool has always worked beautifully, and so functional. Thus, why it was so important for me to get it working again. I am so thankful to have it back again. Thank You!!!