panic with a format string

1,095 views
Skip to first unread message

Carl Shapiro

unread,
Apr 5, 2013, 7:25:51 PM4/5/13
to golang-dev
A number of recent bug reports contain runtime error messages that could be enhanced with additional context.  For example, this error message

runtime error: makeslice: len out of range

might be improved by including the length provided and its maximum possible value.  Those numbers might contain additional clues about what went wrong.

In the case of makeslice, the function runtime.panicstring is called on error.  It is limited to taking a string as an argument.  For better error messages, a varargs form would be required.

I am not sure if there is any history here, but it would be useful to know if there is a specific reason why the error message interface is so limited.






Jan Mercl

unread,
Apr 5, 2013, 7:36:51 PM4/5/13
to Carl Shapiro, golang-dev
I think that information is useful for debugging only. Once one
pinpoints the panic then a simple debug print inserted before the
crash point can reveal what's necessary.

-j

Carl Shapiro

unread,
Apr 5, 2013, 7:45:52 PM4/5/13
to Jan Mercl, golang-dev
On Fri, Apr 5, 2013 at 4:36 PM, Jan Mercl <0xj...@gmail.com> wrote:
I think that information is useful for debugging only. Once one
pinpoints the panic then a simple debug print inserted before the
crash point can reveal what's necessary.

I think this is true in cases when a crash is easy to reproduce.  However, the utility of an error messages increases when the crash is difficult to reproduce.  It also provides additional features for identifying equivalence classes of crashes without having to reproduce the crash.

Albert Strasheim

unread,
Apr 5, 2013, 8:06:53 PM4/5/13
to golan...@googlegroups.com
On Saturday, April 6, 2013 1:25:51 AM UTC+2, Carl Shapiro wrote:
I am not sure if there is any history here, but it would be useful to know if there is a specific reason why the error message interface is so limited.

There is some history. Not sure if anything has changed.

Carl Shapiro

unread,
Apr 5, 2013, 9:22:05 PM4/5/13
to Albert Strasheim, golang-dev
On Fri, Apr 5, 2013 at 5:06 PM, Albert Strasheim <ful...@gmail.com> wrote:
There is some history. Not sure if anything has changed.


That is very useful, thanks.  Panicslice is invoked from generated code when there is an error.  Makeslice, at least, generates an error in runtime code.  All of the context is available.  Fixing panicslice is likely more complicated than makeslice.
Reply all
Reply to author
Forward
0 new messages