Skip to content
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

os: File.Write panic: runtime error: slice bounds out of range #9007

Closed
syndtr opened this issue Oct 28, 2014 · 6 comments
Closed

os: File.Write panic: runtime error: slice bounds out of range #9007

syndtr opened this issue Oct 28, 2014 · 6 comments
Milestone

Comments

@syndtr
Copy link

syndtr commented Oct 28, 2014

What does 'go version' print?

go1.3.3 linux/arm

What steps reproduce the problem?

This happen on Android.
I believe for some reason syscall.Write returns syscall.EINTR error with invalid length,
but I'm not exactly sure what causing this (hardware failure? kernel bug?).

What happened?

panic: runtime error: slice bounds out of range

goroutine 27 [running]:
    /home/vagrant/build/com.nutomic.syncthingandroid/build/go/src/pkg/runtime/panic.c:248 +0xe0
os.(*File).write(0x119a8a30, 0x11a77500, 0xafb, 0x1371, 0xffffffff, 0x0, 0x0)
    /home/vagrant/build/com.nutomic.syncthingandroid/build/go/src/pkg/os/file_unix.go:218 +0xe4
os.(*File).Write(0x119a8a30, 0x11a77500, 0xafb, 0x1371, 0x0, 0x0, 0x0)
    /home/vagrant/build/com.nutomic.syncthingandroid/build/go/src/pkg/os/file.go:139 +0x88
github.com/syndtr/goleveldb/leveldb/table.(*Writer).writeBlock(0x1168e800, 0x1168e82c,
0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/writer.go:190 +0x41c
github.com/syndtr/goleveldb/leveldb/table.(*Writer).finishBlock(0x1168e800, 0x0, 0x0)
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/writer.go:225 +0x98
github.com/syndtr/goleveldb/leveldb/table.(*Writer).Append(0x1168e800, 0x1146b080, 0x9f,
0x160, 0x11d3b002, 0x4, 0x1004, 0x0, 0x0)
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/writer.go:258 +0x300
github.com/syndtr/goleveldb/leveldb.(*tWriter).append(0x11f94270, 0x1146b080, 0x9f,
0x160, 0x11d3b002, 0x4, 0x1004, 0x0, 0x0)
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table.go:481 +0x2c8
github.com/syndtr/goleveldb/leveldb.func·018(0x11869a70, 0x0, 0x0)
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:432 +0x794
github.com/syndtr/goleveldb/leveldb.(*DB).compactionTransact(0x109fe380, 0x481b18, 0xb,
0x114a7e34, 0x114a7dac)
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:173 +0x1c8
github.com/syndtr/goleveldb/leveldb.(*DB).tableCompaction(0x109fe380, 0x119f2200,
0x1fef00)
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:301 +0xbd4
github.com/syndtr/goleveldb/leveldb.(*DB).tableAutoCompaction(0x109fe380)
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:516 +0x54
github.com/syndtr/goleveldb/leveldb.(*DB).tCompaction(0x109fe380)
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:687 +0x280
created by github.com/syndtr/goleveldb/leveldb.openDB
    /home/vagrant/build/com.nutomic.syncthingandroid/ext/syncthing/src/github.com/syncthing/syncthing/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db.go:126 +0x500

What should have happened instead?

Not panic'ing.
@ianlancetaylor
Copy link
Contributor

Comment 1:

I think the code in os is just wrong.  syscall.Write can easily return -1, EINTR.  Or I
suppose we could say that the code in syscall is wrong, but many of the syscalls can
return a non-zero value along with a non-nil error.

Labels changed: added repo-main, release-go1.4.

@ianlancetaylor
Copy link
Contributor

Comment 2:

Can you use strace to verify that write is returning EINTR?  Because, on further
reflection, all the signal handlers are installed with SA_RESTART set, so the write
should restart, not fail.

@rsc
Copy link
Contributor

rsc commented Oct 28, 2014

Comment 3:

This issue was closed by revision a62da20.

Status changed to Fixed.

@syndtr
Copy link
Author

syndtr commented Oct 29, 2014

Comment 4:

> Can you use strace to verify that write is returning EINTR?  Because, on further
reflection, all the signal handlers are installed with SA_RESTART set, so the write
should restart, not fail.
I'm afraid I can't provide you with strace since I'm not exactly experience this myself,
but an user does. But I believe EINTR is only possible error that would trigger this
panic (i.e. nil or other error wouldn't skip sanity check).

@ianlancetaylor
Copy link
Contributor

Comment 5:

I agree that I can't see any way this could fail other than EINTR, but I would still
like to confirm that that is happening.  Because it should be impossible.  If it is
possible there are likely other things that will need to be fixed.  If you can get more
information from the user, that would be very helpful.  Thanks.

@syndtr
Copy link
Author

syndtr commented Oct 29, 2014

Comment 6:

I see. Anyway, here is the issue related to this
syndtr/goleveldb#80.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 26, 2018
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 20, 2018
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 30, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants