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

fmt: surprising undocumented behavior for "String() string" panics #5350

Closed
bcmills opened this issue Apr 24, 2013 · 2 comments
Closed

fmt: surprising undocumented behavior for "String() string" panics #5350

bcmills opened this issue Apr 24, 2013 · 2 comments

Comments

@bcmills
Copy link
Member

@bcmills bcmills commented Apr 24, 2013

The fmt package and other packages that transitively use it (html/template and
text/template in particular) have surprising behavior when the "String()
string" method panics.

I would expect the panic to continue to propagate back to the caller.  But it appears
that fmt.Sprint silently converts panics into strings of the form
"%v(PANIC=%s)".  This behavior is not documented in the fmt, html/template, or
text/template packages.

This leads to cases where non-trivial programs deadlock when one would otherwise expect
a crash with useful stack traces:
http://play.golang.org/p/G9ytQr6EPs

Ideally, the fmt package should not recover any panics at all.

If that's not feasible (e.g. for reasons of backward-compatibility), then at the very
least the behavior of packages that (transitively) use it should be documented.
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 24, 2013

Comment 1:

This is working as intended.
But documenting it sounds like a good idea.
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 29, 2013

Comment 2:

This issue was closed by revision 806dea8.

Status changed to Fixed.

@bcmills bcmills added fixed labels Apr 29, 2013
@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.