-
Notifications
You must be signed in to change notification settings - Fork 2
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
divide by zero panic in hexdump when ConfigState.BytesWidth == 0 #34
Comments
Thanks. The three solutions that I see for this are to: not line-fold if bytes width is zero, panic on call of My personal preference would be to panic with an informative message since this is a programmer error. What is your view? By comparison, spew calls |
Because this is hard to repro (i.e., it only panics on some data structures where the internal logic decides to do a hexDump), it may catch users off-guard at runtime. Our automated tests never hit this condition; we unfortunately didn't catch it until our app crashed in a real environment. If it crashed unconditionally, I'd agree with you. IMHO I'd prefer either not line-folding if width is unset, or (if that is considered a silently breaking change to existing users), panicking immediately on any of the following if the config is invalid:
Or if those options are unpalatable, you could deprecate the public |
I have #35 (this will be 1.7.0 after it's merged). This sets the width to 16 if it's unset or negative. I took a look at making the output unfolded, and I don't particularly like it; it's harder to do and given the kinds of values that I decided against a panic (it would not have been immediately on the call to the exported function since width is not necessarily used, but would have been in the preamble to |
We encountered this error with utter v1.5.0. In the process of migrating from spew to utter, we were constructing
ConfigState
without specifying any width values. After seeing this we realized we needed to useConfigState.NewDefaultConfig()
(or set valid values for the config fields). I thought I would mention it, in case the maintainers wanted to validate the config before trying to serialize the data.stack trace:
The text was updated successfully, but these errors were encountered: