FAQ
I'm hitting a problem unmarshaling JSON. (Full details below.) I see two
old bugs, #3614 and #977, which are both fixed. They look like the same
problem, but the test cases for them don't cause problems in my Go
installation. I can't tell if I have found a new bug, or if I'm doing
something wrong. Before posting bug report I wanted to ask here. Tell me if
this is wrong and I should post bug report.

Thanks,
Boris

2012/12/11 20:10:50 http: panic serving [::1]:53652: interface conversion:
string is not error: missing method Error
/usr/local/go/src/pkg/net/http/server.go:589 (0x3da79)
_func_004: buf.Write(debug.Stack())
/usr/local/go/src/pkg/runtime/proc.c:1443 (0xf070)
panic: reflect·call(d->fn, d->args, d->siz);
/usr/local/go/src/pkg/runtime/iface.c:127 (0x6e85)
itab: runtime·panic(err);
/usr/local/go/src/pkg/runtime/iface.c:461 (0x772d)
ifaceE2I: ret->tab = itab(inter, t, 0);
/usr/local/go/src/pkg/runtime/iface.c:476 (0x77b7)
assertE2I: runtime·ifaceE2I(inter, e, &ret);
/usr/local/go/src/pkg/encoding/json/decode.go:123 (0x6c440)
_func_001: err = r.(error)
/usr/local/go/src/pkg/runtime/proc.c:1443 (0xf070)
panic: reflect·call(d->fn, d->args, d->siz);
/usr/local/go/src/pkg/reflect/value.go:1782 (0x5b4a5)
Value.assignTo: panic(context + ": value of type " + v.typ.String() + " is
not assignable to type " + dst.String())
/usr/local/go/src/pkg/reflect/value.go:1197 (0x59497)
Value.Set: x = x.assignTo("reflect.Set", v.typ, target)
/usr/local/go/src/pkg/encoding/json/decode.go:426 (0x6382d)
(*decodeState).object: iv.Set(reflect.ValueOf(d.objectInterface()))
/usr/local/go/src/pkg/encoding/json/decode.go:249 (0x62a1d)
(*decodeState).value: d.object(v)
/usr/local/go/src/pkg/encoding/json/decode.go:375 (0x634aa)
(*decodeState).array: d.value(v.Index(i))
/usr/local/go/src/pkg/encoding/json/decode.go:246 (0x62a38)
(*decodeState).value: d.array(v)
/usr/local/go/src/pkg/encoding/json/decode.go:555 (0x63fb5)
(*decodeState).object: d.value(subv)
/usr/local/go/src/pkg/encoding/json/decode.go:249 (0x62a1d)
(*decodeState).value: d.object(v)
/usr/local/go/src/pkg/encoding/json/decode.go:136 (0x62580)
(*decodeState).unmarshal: d.value(rv)
/usr/local/go/src/pkg/encoding/json/decode.go:65 (0x621b2)
Unmarshal: return d.unmarshal(v)
/Users/boris/Documents/go/src/github.com/boris/go/nap/request.go:49(0x261f2)
com/boris/go/nap.(*Request).ReadEntity: err = json.Unmarshal(buffer, &obj)
/Users/boris/Documents/go/src/
github.com/boris/go/servers/api-server/instance/instance.go:45 (0x28d29)
com/boris/go/servers/api-server/instance.updateInstances: err :=
req.ReadEntity(instances)
/Users/boris/Documents/go/src/github.com/boris/go/nap/service.go:122(0x27df0)
com/boris/go/nap._func_001: handler(req, &res)
/usr/local/go/src/pkg/net/http/server.go:703 (0x328ea)
HandlerFunc.ServeHTTP: f(w, r)
/usr/local/go/src/pkg/net/http/server.go:941 (0x334ca)
(*ServeMux).ServeHTTP: mux.handler(r).ServeHTTP(w, r)
/usr/local/go/src/pkg/net/http/server.go:669 (0x3273c)
(*conn).serve: handler.ServeHTTP(w, w.req)
/usr/local/go/src/pkg/runtime/proc.c:271 (0xd562)
goexit: runtime·goexit(void)

--

Search Discussions

  • Kyle Lemons at Dec 12, 2012 at 3:49 am
    Can you provide an example of the JSON and the Go type into which you are
    unmarshaling? I can see that it's something inside an object inside an
    array inside an object, but not a whole lot more :).

    It looks like there are potentially 3 errors here... you may have an
    incompatibility in your JSON/Type which is not checked by the JSON library
    which then causes reflect to panic which then triggers a problem in the
    HTTP defers :).

    On Tue, Dec 11, 2012 at 8:42 PM, Boris Solovyov wrote:

    I'm hitting a problem unmarshaling JSON. (Full details below.) I see two
    old bugs, #3614 and #977, which are both fixed. They look like the same
    problem, but the test cases for them don't cause problems in my Go
    installation. I can't tell if I have found a new bug, or if I'm doing
    something wrong. Before posting bug report I wanted to ask here. Tell me if
    this is wrong and I should post bug report.

    Thanks,
    Boris

    2012/12/11 20:10:50 http: panic serving [::1]:53652: interface conversion:
    string is not error: missing method Error
    /usr/local/go/src/pkg/net/http/server.go:589 (0x3da79)
    _func_004: buf.Write(debug.Stack())
    /usr/local/go/src/pkg/runtime/proc.c:1443 (0xf070)
    panic: reflect·call(d->fn, d->args, d->siz);
    /usr/local/go/src/pkg/runtime/iface.c:127 (0x6e85)
    itab: runtime·panic(err);
    /usr/local/go/src/pkg/runtime/iface.c:461 (0x772d)
    ifaceE2I: ret->tab = itab(inter, t, 0);
    /usr/local/go/src/pkg/runtime/iface.c:476 (0x77b7)
    assertE2I: runtime·ifaceE2I(inter, e, &ret);
    /usr/local/go/src/pkg/encoding/json/decode.go:123 (0x6c440)
    _func_001: err = r.(error)
    /usr/local/go/src/pkg/runtime/proc.c:1443 (0xf070)
    panic: reflect·call(d->fn, d->args, d->siz);
    /usr/local/go/src/pkg/reflect/value.go:1782 (0x5b4a5)
    Value.assignTo: panic(context + ": value of type " + v.typ.String() + " is
    not assignable to type " + dst.String())
    /usr/local/go/src/pkg/reflect/value.go:1197 (0x59497)
    Value.Set: x = x.assignTo("reflect.Set", v.typ, target)
    /usr/local/go/src/pkg/encoding/json/decode.go:426 (0x6382d)
    (*decodeState).object: iv.Set(reflect.ValueOf(d.objectInterface()))
    /usr/local/go/src/pkg/encoding/json/decode.go:249 (0x62a1d)
    (*decodeState).value: d.object(v)
    /usr/local/go/src/pkg/encoding/json/decode.go:375 (0x634aa)
    (*decodeState).array: d.value(v.Index(i))
    /usr/local/go/src/pkg/encoding/json/decode.go:246 (0x62a38)
    (*decodeState).value: d.array(v)
    /usr/local/go/src/pkg/encoding/json/decode.go:555 (0x63fb5)
    (*decodeState).object: d.value(subv)
    /usr/local/go/src/pkg/encoding/json/decode.go:249 (0x62a1d)
    (*decodeState).value: d.object(v)
    /usr/local/go/src/pkg/encoding/json/decode.go:136 (0x62580)
    (*decodeState).unmarshal: d.value(rv)
    /usr/local/go/src/pkg/encoding/json/decode.go:65 (0x621b2)
    Unmarshal: return d.unmarshal(v)
    /Users/boris/Documents/go/src/github.com/boris/go/nap/request.go:49(0x261f2)
    com/boris/go/nap.(*Request).ReadEntity: err = json.Unmarshal(buffer, &obj)
    /Users/boris/Documents/go/src/
    github.com/boris/go/servers/api-server/instance/instance.go:45 (0x28d29)
    com/boris/go/servers/api-server/instance.updateInstances: err :=
    req.ReadEntity(instances)
    /Users/boris/Documents/go/src/github.com/boris/go/nap/service.go:122(0x27df0)
    com/boris/go/nap._func_001: handler(req, &res)
    /usr/local/go/src/pkg/net/http/server.go:703 (0x328ea)
    HandlerFunc.ServeHTTP: f(w, r)
    /usr/local/go/src/pkg/net/http/server.go:941 (0x334ca)
    (*ServeMux).ServeHTTP: mux.handler(r).ServeHTTP(w, r)
    /usr/local/go/src/pkg/net/http/server.go:669 (0x3273c)
    (*conn).serve: handler.ServeHTTP(w, w.req)
    /usr/local/go/src/pkg/runtime/proc.c:271 (0xd562)
    goexit: runtime·goexit(void)

    --

    --
  • Boris Solovyov at Dec 12, 2012 at 12:14 pm
    There is a lot of code. I will try to make a minimal test case. I think
    http is not really part of the problem, so maybe I can make something with
    just JSON.

    On Tue, Dec 11, 2012 at 10:48 PM, Kyle Lemons wrote:

    Can you provide an example of the JSON and the Go type into which you are
    unmarshaling? I can see that it's something inside an object inside an
    array inside an object, but not a whole lot more :).

    It looks like there are potentially 3 errors here... you may have an
    incompatibility in your JSON/Type which is not checked by the JSON library
    which then causes reflect to panic which then triggers a problem in the
    HTTP defers :).

    On Tue, Dec 11, 2012 at 8:42 PM, Boris Solovyov wrote:

    I'm hitting a problem unmarshaling JSON. (Full details below.) I see two
    old bugs, #3614 and #977, which are both fixed. They look like the same
    problem, but the test cases for them don't cause problems in my Go
    installation. I can't tell if I have found a new bug, or if I'm doing
    something wrong. Before posting bug report I wanted to ask here. Tell me if
    this is wrong and I should post bug report.

    Thanks,
    Boris

    2012/12/11 20:10:50 http: panic serving [::1]:53652: interface
    conversion: string is not error: missing method Error
    /usr/local/go/src/pkg/net/http/server.go:589 (0x3da79)
    _func_004: buf.Write(debug.Stack())
    /usr/local/go/src/pkg/runtime/proc.c:1443 (0xf070)
    panic: reflect·call(d->fn, d->args, d->siz);
    /usr/local/go/src/pkg/runtime/iface.c:127 (0x6e85)
    itab: runtime·panic(err);
    /usr/local/go/src/pkg/runtime/iface.c:461 (0x772d)
    ifaceE2I: ret->tab = itab(inter, t, 0);
    /usr/local/go/src/pkg/runtime/iface.c:476 (0x77b7)
    assertE2I: runtime·ifaceE2I(inter, e, &ret);
    /usr/local/go/src/pkg/encoding/json/decode.go:123 (0x6c440)
    _func_001: err = r.(error)
    /usr/local/go/src/pkg/runtime/proc.c:1443 (0xf070)
    panic: reflect·call(d->fn, d->args, d->siz);
    /usr/local/go/src/pkg/reflect/value.go:1782 (0x5b4a5)
    Value.assignTo: panic(context + ": value of type " + v.typ.String() + "
    is not assignable to type " + dst.String())
    /usr/local/go/src/pkg/reflect/value.go:1197 (0x59497)
    Value.Set: x = x.assignTo("reflect.Set", v.typ, target)
    /usr/local/go/src/pkg/encoding/json/decode.go:426 (0x6382d)
    (*decodeState).object: iv.Set(reflect.ValueOf(d.objectInterface()))
    /usr/local/go/src/pkg/encoding/json/decode.go:249 (0x62a1d)
    (*decodeState).value: d.object(v)
    /usr/local/go/src/pkg/encoding/json/decode.go:375 (0x634aa)
    (*decodeState).array: d.value(v.Index(i))
    /usr/local/go/src/pkg/encoding/json/decode.go:246 (0x62a38)
    (*decodeState).value: d.array(v)
    /usr/local/go/src/pkg/encoding/json/decode.go:555 (0x63fb5)
    (*decodeState).object: d.value(subv)
    /usr/local/go/src/pkg/encoding/json/decode.go:249 (0x62a1d)
    (*decodeState).value: d.object(v)
    /usr/local/go/src/pkg/encoding/json/decode.go:136 (0x62580)
    (*decodeState).unmarshal: d.value(rv)
    /usr/local/go/src/pkg/encoding/json/decode.go:65 (0x621b2)
    Unmarshal: return d.unmarshal(v)
    /Users/boris/Documents/go/src/github.com/boris/go/nap/request.go:49(0x261f2)
    com/boris/go/nap.(*Request).ReadEntity: err = json.Unmarshal(buffer, &obj)
    /Users/boris/Documents/go/src/
    github.com/boris/go/servers/api-server/instance/instance.go:45 (0x28d29)
    com/boris/go/servers/api-server/instance.updateInstances: err :=
    req.ReadEntity(instances)
    /Users/boris/Documents/go/src/github.com/boris/go/nap/service.go:122(0x27df0)
    com/boris/go/nap._func_001: handler(req, &res)
    /usr/local/go/src/pkg/net/http/server.go:703 (0x328ea)
    HandlerFunc.ServeHTTP: f(w, r)
    /usr/local/go/src/pkg/net/http/server.go:941 (0x334ca)
    (*ServeMux).ServeHTTP: mux.handler(r).ServeHTTP(w, r)
    /usr/local/go/src/pkg/net/http/server.go:669 (0x3273c)
    (*conn).serve: handler.ServeHTTP(w, w.req)
    /usr/local/go/src/pkg/runtime/proc.c:271 (0xd562)
    goexit: runtime·goexit(void)

    --

    --
  • Boris Solovyov at Dec 12, 2012 at 12:40 pm
    Here is sort-of-minimal testcase: http://play.golang.org/p/fFyr3j42oH

    --
  • Dave Cheney at Dec 12, 2012 at 1:13 pm
    I have a fix for the double panic , I'll try to post it tomorrow.
    On 12 Dec 2012 23:40, "Boris Solovyov" wrote:

    Here is sort-of-minimal testcase: http://play.golang.org/p/fFyr3j42oH

    --

    --
  • Boris Solovyov at Dec 12, 2012 at 1:32 pm
    Can anyone think of a workaround or way to avoid the problem? I don't
    understand what is wrong, so I don't know how else I can do this without
    triggering the issue.

    On Wed, Dec 12, 2012 at 8:13 AM, Dave Cheney wrote:

    I have a fix for the double panic , I'll try to post it tomorrow.
    On 12 Dec 2012 23:40, "Boris Solovyov" wrote:

    Here is sort-of-minimal testcase: http://play.golang.org/p/fFyr3j42oH

    --

    --
  • John Asmuth at Dec 12, 2012 at 1:36 pm
    How can the JSON package know that you want to use SubType1 or SubType2 (or
    anything) for the items? There simply isn't enough information to do this,
    the way you have it. When JSON puts data into an interface of any kind, it
    uses a map[string]interface{}. Unfortunately the map has no methods, so you
    get the panic.
    On Wednesday, December 12, 2012 7:40:21 AM UTC-5, Boris wrote:

    Here is sort-of-minimal testcase: http://play.golang.org/p/fFyr3j42oH
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 12, '12 at 1:42a
activeDec 12, '12 at 1:36p
posts7
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase