fsnotify: Panic on Mac OS X when debugging
Before reporting an issue, please ensure you are using the latest release of fsnotify.
Which operating system (GOOS) and version are you using?
OS: ProductName: Mac OS X ProductVersion: 10.12.5 BuildVersion: 16F73
Go: go version go1.8.3 darwin/amd64
Delve: Delve Debugger Version: 1.0.0-rc.1 Build:
IDE: Visual Studio Code Ver 1.14.1 (1.14.1) 2648980a697a4c8fb5777dcfb2ab110cec8a2f58 2017-07-13T19:05:02.227Z
Please describe the issue that occurred.
When execution continues after stop at breakpoint then panic raised at kqueue.go -> read(kq int, events []unix.Kevent_t, timeout *unix.Timespec)
Are you able to reproduce the issue? Please provide steps to reproduce and a code sample if possible.
- I use sample code from https://github.com/fsnotify/fsnotify/blob/master/example_test.go
- Set up breakpoint at any place
- Trigger breakpoint
- When step over or continue execution then panic raised
panic: runtime error: slice bounds out of range
goroutine 8 [running]:
bitbucket.org/project/vendor/github.com/fsnotify/fsnotify.read(0x8, 0xc4202e0e88, 0xa, 0xa, 0x1708c50, 0xc4202e0e88, 0x0, 0xa, 0x0, 0x0)
/path_to_project/vendor/github.com/fsnotify/fsnotify/kqueue.go:498 +0x2fe
bitbucket.org/litkiosk/litkiosk_server/vendor/github.com/fsnotify/fsnotify.(*Watcher).readEvents(0xc42001c360)
/path_to_project/vendor/github.com/fsnotify/fsnotify/kqueue.go:284 +0xda
created by bitbucket.org/litkiosk/litkiosk_server/vendor/github.com/fsnotify/fsnotify.NewWatcher
/path_to_project/vendor/github.com/fsnotify/fsnotify/kqueue.go:62 +0x2c8
I added log in this function
func read(kq int, events []unix.Kevent_t, timeout *unix.Timespec) ([]unix.Kevent_t, error) {
n, err := unix.Kevent(kq, nil, events, timeout)
if err != nil {
return nil, err
}
fmt.Println("n", n, "len", len(events), "cap", cap(events))
return events[0:n], nil
}
and it prints
n 0 len 10 cap 10
n 0 len 10 cap 10
n 0 len 10 cap 10
n 0 len 10 cap 10
2017/07/15 12:00:40 debugger.go:505: continuing
n 33554795 len 10 cap 10
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 22
- Comments: 18 (2 by maintainers)
Commits related to this issue
- Temporary fix for osx debug panic https://github.com/fsnotify/fsnotify/issues/212#issuecomment-360862770 — committed to nwingert/fsnotify by nwingert 6 years ago
I have been able to work around the panic by making the following modification in kqueue.go:
+1 I have added some code to avoid this issue on my local machine
kquene.go
Same issue with GoLand and https://www.jetbrains.com/go/