Skip to content

Segfault when writing to a TCPCon #277

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

Closed
gopherbot opened this issue Nov 20, 2009 · 2 comments
Closed

Segfault when writing to a TCPCon #277

gopherbot opened this issue Nov 20, 2009 · 2 comments

Comments

@gopherbot
Copy link
Contributor

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:

  1. irc.go (2433 bytes)
  2. main.go (2115 bytes)
@rsc
Copy link
Contributor

rsc commented Nov 20, 2009

Comment 1:

Seg faults happen in Go code when you dereference a nil pointer
or call a method on a nil interface, etc.
Looks like getConnFromUsername returned nil.

Owner changed to [email protected].

Status changed to Invalid.

@gopherbot
Copy link
Contributor Author

Comment 2 by myspot40:

Thanks, when I told my situation to #go-nuts on freenode, they said that it should
not be possible and that I should post here

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
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

2 participants