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

json crash on {} input #1017

Closed
gopherbot opened this issue Aug 10, 2010 · 2 comments
Closed

json crash on {} input #1017

gopherbot opened this issue Aug 10, 2010 · 2 comments

Comments

@gopherbot
Copy link
Contributor

by fibercut:

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. main.go
package main

import (
    "log"
    "net"
    "rpc"
    "rpc/jsonrpc"
)

func main() {
    l, e := net.Listen("tcp", "127.0.0.1:12345")
    if e != nil {
        log.Exit("Could not open port: %s\n", e)
    }
    for {
        conn, _ := l.Accept()
        rpc.ServeCodec(jsonrpc.NewServerCodec(conn))
    }
}

2. telnet 127.0.0.1 12345
3. type {} <enter>

What is the expected output?

it's expected not to crash

What do you see instead?

% ./empty_string     
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference

panic PC=0xa76b68
runtime.panic+0xa9 /opt/go/src/src/pkg/runtime/proc.c:1012
    runtime.panic(0x0, 0x2)
json._func_003+0x72 /opt/go/src/src/pkg/json/encode.go:155
    json._func_003(0x80fe1b4, 0xa8a0f0, 0xa8a0f0, 0xa7fca0)
runtime.panic+0xe9 /opt/go/src/src/pkg/runtime/proc.c:994
    runtime.panic(0xa7f6e0, 0xa7f754)
panicstring+0x61 /opt/go/src/src/pkg/runtime/runtime.c:83
    panicstring(0x80fe1b4, 0xa8a0f0)
sigpanic+0x11b /opt/go/src/src/pkg/runtime/linux/thread.c:286
    sigpanic()
json.*RawMessage·MarshalJSON+0x26 /opt/go/src/src/pkg/json/stream.go:172
    json.*RawMessage·MarshalJSON(0x1, 0xa634cc, 0x80b1fb6)
json.*encodeState·reflectValue+0xb4 /opt/go/src/src/pkg/json/encode.go:175
    json.*encodeState·reflectValue(0x0, 0x80e73d0, 0x0)
json.*encodeState·reflectValue+0x797 /opt/go/src/src/pkg/json/encode.go:222
    json.*encodeState·reflectValue(0xa810e8, 0xa7ea20, 0xa809c0)
json.*encodeState·marshal+0x86 /opt/go/src/src/pkg/json/encode.go:160
    json.*encodeState·marshal(0xa810e8, 0xab8450, 0xa809b0, 0xa809b0, 0x0, ...)
json.*Encoder·Encode+0x65 /opt/go/src/src/pkg/json/stream.go:146
    json.*Encoder·Encode(0xa810e8, 0x813163c, 0xa7f5a0, 0x1, 0x3, ...)
rpc/jsonrpc.*serverCodec·WriteResponse+0x175
/opt/go/src/src/pkg/rpc/jsonrpc/server.go:111
    rpc/jsonrpc.*serverCodec·WriteResponse(0xa810e0, 0x813163c, 0xa7f5a0, 0x1, 0x810742c, ...)
rpc.sendResponse+0xb4 /opt/go/src/src/pkg/rpc/server.go:290
    rpc.sendResponse(0xa72eb0, 0xa7f820, 0x810e2b0, 0x1, 0xffffffff, ...)
rpc.*serverType·input+0x33f /opt/go/src/src/pkg/rpc/server.go:358
    rpc.*serverType·input(0xa60a98, 0xa80980, 0x810e2b0)
rpc.ServeCodec+0x36 /opt/go/src/src/pkg/rpc/server.go:435
    rpc.ServeCodec(0xa80640, 0xab8420)
main.main+0x15e /home/sven/git/bugs/empty_string/empty_string.go:28
    main.main()
mainstart+0xf /opt/go/src/src/pkg/runtime/386/asm.s:83
    mainstart()
goexit /opt/go/src/src/pkg/runtime/proc.c:145
    goexit()

goroutine 2 [3]:
runtime.entersyscall+0x3c /opt/go/src/src/pkg/runtime/proc.c:558
    runtime.entersyscall()
syscall.Syscall6+0x5 /opt/go/src/src/pkg/syscall/asm_linux_386.s:313
    syscall.Syscall6()
syscall.EpollWait+0x74 /opt/go/src/src/pkg/syscall/zsyscall_linux_386.go:146
    syscall.EpollWait(0x100, 0x6, 0xa801e0, 0x1, 0xffffffff, ...)
net.*pollster·WaitFD+0x134 /opt/go/src/src/pkg/net/fd_linux.go:116
    net.*pollster·WaitFD(0x6, 0xa801e0, 0x1, 0x1, 0xffffffff, ...)
net.*pollServer·Run+0xcb /opt/go/src/src/pkg/net/fd.go:208
    net.*pollServer·Run(0xa60878, 0x0)
goexit /opt/go/src/src/pkg/runtime/proc.c:145
    goexit()

What is your $GOOS?  $GOARCH?

linux 386

Which revision are you using?  (hg identify)

8884f7b4c775 release.2010-08-04/release
@gopherbot
Copy link
Contributor Author

Comment 1 by fibercut:

subject should be: crash on input of {}

@rsc
Copy link
Contributor

rsc commented Aug 17, 2010

Comment 3:

This issue was closed by revision 8dc4c0b.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
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