-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[signal SIGBUS: bus error code=0x2 addr=0x1e4001 pc=0x2535] #12
Comments
me too :( |
the same problem |
A minimal reproduction case would be helpful here. |
@edsrzf I hit the same problem on macos. This reproduced when provided mapped size is bigger than actual file size. So, in my case the code, called for a file f which size is 0:
doesn't change the file f size, so it remained 0. Seems like macos doesn't extend the file with the mapping. Can be easily fixed by |
I've also been investigating this, and made a repro for it. I can repro it on both fedora and ubuntu. However, IIUC, it's not actually an issue with mmap per se, rather a filesystem thing. See https://gist.github.com/holiman/ce51945058d2befaf718de3804fb9352 . What that gist does, is that it creates a file, in the os temp folder, of If I check the file,
So what we've got is a 'sparse' file. And even though it's possible to read 10Gb from it, the underlying disk resource is way smaller. And the problem is that if I later try to fill it with data, at some point the underlying disk resource will grow larger than what the disk can hold ( in my case Back to mmap: in our use of mmap-go, we create a large file, truncate to size, close, and then do an mmap on it -- erroneously believing that we can use the full size of the mmap data, as it's already backed by the filesystem. Later on, as we're just filling the bytes, the same thing will happen though, and I'm not sure how this can be avoided. One (boring) solution could be to actually fill the file with data, write junk to it before mmap, to ensure that the disk actually will be able to store the data. |
For memory maps where the caller intends to write to the region, a check like this can be used to ensure that the required size is actually addressable:
More info: https://unix.stackexchange.com/a/292849 It's obviously unix-specific. |
It's linux specific¹. Other unix variants do not have fallocate. As with all use of package ¹ The first paragraph of the
|
go version
1.7.1
os
macos sierra
when i use mmap-go to write bytes to file occur error. the stack as below
unexpected fault address 0x1e4001
fatal error: fault
[signal SIGBUS: bus error code=0x2 addr=0x1e4001 pc=0x2535]
goroutine 1 [running]:
runtime.throw(0xb37ee, 0x5)
/usr/local/go/src/runtime/panic.go:566 +0x95 fp=0xc420035da0 sp=0xc420035d80
runtime.sigpanic()
/usr/local/go/src/runtime/sigpanic_unix.go:21 +0x1d0 fp=0xc420035df8 sp=0xc420035da0
main.main()
/Users/leizhenyu/work/src/github.com/GoRocketMQ/start/main-1.go:58 +0x4f5 fp=0xc420035f48 sp=0xc420035df8
runtime.main()
/usr/local/go/src/runtime/proc.go:183 +0x1f4 fp=0xc420035fa0 sp=0xc420035f48
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc420035fa8 sp=0xc420035fa0
exit status 2
the line 58 code as below
mmaped[0] = 'x'
The text was updated successfully, but these errors were encountered: