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
Panic on OpenBSD #146
Comments
Hi, thanks for filing this issue. Based on this stack trace, it looks like you're calling pty.StartWithAttrs with a nil pointer as the first argument. Here's the relevant line from the stacktrace:
The
I hope this helps! |
Yes, I am still looking into how this could happen, however, I feel like causing a crash should not be the go-to method of error handling. Instead a check whether it's nil and a corresponding error would be a better solution. |
It is appropriate to panic when client code supplies a nil pointer as an argument that's not meant to take a nil pointer. That's the usual (and, in my opinion, best) way to do it in Go. |
I think the "Don't Panic" Proverb sums this up pretty well. This is an error, not an issue that may lead to inconsistent state. If nil is provided that is an obvious error and should be handled gracefully instead of by blowing up. |
And as far as it being the usual way, I have a hard time finding such behaviour in either stdlib or 3rd party libraries. |
"Don't panic" is for runtime errors such as bad user input, out of disk, etc, not for bugs. It's not clear if this issue leads to inconsistent state, but it does indicate inconsistent state already exists. When we reach this point in the code, we know something has happened that the program author didn't intend. By definition, the application doesn't know what its state ought to be. In other words, a bug. Here are some examples of panic-on-bug (specifically, panic-on-nil) from the standard library: https://go.dev/play/p/GU9WI0TvdKI I picked a few functions at random, these are just the first four I tried. |
Interesting, thanks. Never noticed that… Thanks for showing me. |
It seems like there's nothing for this package to do here, so I'm gonna close this issue. But feel free to comment here or open a new issue if I've missed anything. Thanks again! |
Fix race when closing a terminal. The race appears as a nil pointer dereference panic in pty.StartWithAttrs when trying to access the provided term.cmd variable. Before calling pty.StartwithAttrs in the Terminal.Draw function, term.cmd is checked for nil. Terminal.Close must be called concurrently right after this check and before/while entering pty.StartWithAttrs. This can be avoided with a mutex. Link: creack/pty#146 Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CCJ2I45HMOTGD.2J1QMEJ4T1E3N%40t450.arielp.com%3E#%3CCJ3D069RCTXL.3VEZ7JIGFHOHK@Archetype%3E Fixes: https://todo.sr.ht/~rjarry/aerc/38 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Hi, I'm one of the developers of aerc and we received a report from a user with a crash caused by pty.
The report is here and if questions come up, please feel free to ask in this thread. Maybe the Stack Trace will be enough to find and fix the issue though.
aerc-crash-20220405-134420.log
The text was updated successfully, but these errors were encountered: