Closed
Description
by myspot40:
I somehow managed to trigger a segfault with Go code. From what I understand, this should not happen at all. A friend and I are trying to make a rudimentary IRC server in Go, and I was testing NICK and PRIVMSG when this occured. I telneted to localhost at port 6667 in two terminals while running this server. First I entered PASS into both terminals, it is ignored by the server correctly. Then I entered 'NICK foo' in one terminal and 'NICK bar' in another. After getting sidetracked, I forgot I nicked the connections, and ran both commands again, except this time 'NICK foo' was in the second terminal while 'NICK bar' was in the first. I then tried to send a PRIVMSG from foo to bar, and generated the segfault. Here is the full output while I ran the server: $ ./GoGet 2009/11/19 20:48:25 STARTING SERVER... 2009/11/19 20:48:29 Connection accepted:127.0.0.1:53787 2009/11/19 20:48:36 foo HAS REGISTERED A NICK &{foo ����� []} &{foo NICK [bar]} 2009/11/19 20:48:47 bar HAS REGISTERED A NICK &{bar PRIVMSG [foo :hi]} SIGSEGV: segmentation violation Faulting address: 0x28 PC=0x400b1c main·sendMessage+0xa4 /home/me/Code/Go/GoGet/src/main.go:44 main·sendMessage(0x0, 0x0, 0x0, 0x0, 0x0, ...) main·parseLine+0x1d1 /home/me/Code/Go/GoGet/src/main.go:55 main·parseLine(0x413b50c0, 0x7fb6, 0x13, 0x7fb6, 0x4131f420, ...) main·handleConnection+0x22a /home/me/Code/Go/GoGet/src/main.go:73 main·handleConnection(0x4131f420, 0x7fb6) goexit /home/me/go/src/pkg/runtime/proc.c:135 goexit() 0x7fb64131f420 unknown pc goroutine 3: gosched+0x34 /home/me/go/src/pkg/runtime/proc.c:516 gosched() chanrecv+0x130 /home/me/go/src/pkg/runtime/chan.c:345 chanrecv(0x4131d4b0, 0x7fb6, 0x41356088, 0x7fb6, 0x0, ...) runtime·chanrecv1+0x50 /home/me/go/src/pkg/runtime/chan.c:415 runtime·chanrecv1(0x4131d4b0, 0x7fb6) net·*pollServer·WaitRead+0x49 /home/me/go/src/pkg/net/fd.go:278 net·*pollServer·WaitRead(0x4131c340, 0x7fb6, 0x413523f0, 0x7fb6) net·*netFD·accept+0x2af /home/me/go/src/pkg/net/fd.go:424 net·*netFD·accept(0x413523f0, 0x7fb6, 0x40bd8d, 0x0, 0x413525a0, ...) net·*TCPListener·AcceptTCP+0x5a /home/me/go/src/pkg/net/tcpsock.go:253 net·*TCPListener·AcceptTCP(0x41316a10, 0x7fb6, 0x0, 0x0, 0x0, ...) net·*TCPListener·Accept+0x34 /home/me/go/src/pkg/net/tcpsock.go:263 net·*TCPListener·Accept(0x41316a10, 0x7fb6, 0x0, 0x0, 0x0, ...) main·getConnections+0x1c /home/me/Code/Go/GoGet/src/main.go:20 main·getConnections(0x41316a10, 0x7fb6, 0x4131d550, 0x7fb6) goexit /home/me/go/src/pkg/runtime/proc.c:135 goexit() 0x7fb641316a10 unknown pc goroutine 2: runtime·entersyscall+0x50 /home/me/go/src/pkg/runtime/proc.c:540 runtime·entersyscall() syscall·Syscall6+0x5 /home/me/go/src/pkg/syscall/asm_linux_amd64.s:41 syscall·Syscall6() syscall·EpollWait+0x84 /home/me/go/src/pkg/syscall/zsyscall_linux_amd64.go:132 syscall·EpollWait(0x6, 0x7fb6, 0x4138a580, 0x7fb6, 0x1, ...) net·*pollster·WaitFD+0xb5 /home/me/go/src/pkg/net/fd_linux.go:116 net·*pollster·WaitFD(0x4134ea80, 0x7fb6, 0x0, 0x0, 0x72, ...) net·*pollServer·Run+0x9e /home/me/go/src/pkg/net/fd.go:237 net·*pollServer·Run(0x4131c340, 0x7fb6) goexit /home/me/go/src/pkg/runtime/proc.c:135 goexit() 0x7fb64131c340 unknown pc goroutine 1: gosched+0x34 /home/me/go/src/pkg/runtime/proc.c:516 gosched() chanrecv+0x318 /home/me/go/src/pkg/runtime/chan.c:319 chanrecv(0x4131d550, 0x7fb6, 0x41353f38, 0x7fb6, 0x0, ...) runtime·chanrecv1+0x50 /home/me/go/src/pkg/runtime/chan.c:415 runtime·chanrecv1(0x4131d550, 0x7fb6) main·main+0xe6 /home/me/Code/Go/GoGet/src/main.go:88 main·main() mainstart+0xf /home/me/go/src/pkg/runtime/amd64/asm.s:55 mainstart() goexit /home/me/go/src/pkg/runtime/proc.c:135 goexit() rax 0xe rbx 0x0 rcx 0xd rdx 0x7fb64138a780 rdi 0x7fb6413a2e78 rsi 0x7fb6413a2e80 rbp 0x0 rsp 0x7fb6413a2e60 r8 0x7fb64138a790 r9 0x7fb6413a2d40 r10 0x79 r11 0x246 r12 0x2 r13 0x7fff35e60c10 r14 0x486980 r15 0x7fb641397090 rip 0x400b1c rflags 0x10202 cs 0x33 fs 0x0 gs 0x0 zsh: trace trap ./GoGet Attached are the two source files I have.
Attachments: