2

my wired situation is, the online service is working now, and everyday i can find a few 500 error reports like below:

2018-12-19 00:00:01     [ERROR] path[/vplay/getIdsInfo/?type=vlist&ids=31105228] err[runtime error: index out of range] stack[
goweb.(*RouterTab).ServeHTTP.func3.1:/home/tanxiaolong/golib/src/goweb/router.go:352
runtime.call64:/usr/local/go/src/runtime/asm_amd64.s:574
runtime.gopanic:/usr/local/go/src/runtime/panic.go:505
runtime.panicindex:/usr/local/go/src/runtime/panic.go:28
models.(*VplayModel).AssembleData:/home/tanxiaolong/golib/src/vplay/models/vplay.go:757
controllers.(*VplayController).GetIdsInfoAction:/home/tanxiaolong/golib/src/vplay/controllers/vplay.go:652
runtime.call32:/usr/local/go/src/runtime/asm_amd64.s:573
reflect.Value.call:/usr/local/go/src/reflect/value.go:447
reflect.Value.Call:/usr/local/go/src/reflect/value.go:308
goweb.(*RouterTab).ServeHTTP.func3:/home/tanxiaolong/golib/src/goweb/router.go:370
runtime.goexit:/usr/local/go/src/runtime/asm_amd64.s:2361]      (goweb/router.go:353)

i can find which api by log, but it returns 200 and correct response data if request it with the same query data as 500 requests by myself or wrk or ab.

i don't know how to debug this bug..

any suggestions on api debugging??

many thanks!

3
  • 1
    we need the code that generates the runtime error. Commented Dec 19, 2018 at 4:13
  • 2
    from the stack trace it's clear that the panic happen on router.go:352. we still need the code. not just the stack trace. Commented Dec 19, 2018 at 4:24
  • 1
    i found that bug along with the stack tips~ thank your tips too! Commented Dec 19, 2018 at 4:52

1 Answer 1

2

When you're handling errors you can use:

err.(*errors.Error).ErrorStack()

to return the stacktrace. With that you can get the line in which your API in some cases gets an index out of range error.

Sign up to request clarification or add additional context in comments.

3 Comments

i used a error stack print,and i pick the one i understand attached. :-P i dont know why i curl the api with 200 returns and the online service is sometime 500 returns. i doubt that the online requests mess the goroutines up, but i have no proofs..
Nice, now we need the file vplay.go in the line 652 and everything related to it.
ah, i found the bug~ indeed a index out of a slice. thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.