News for hackers. Stuff that matters.
Re:Long Error Messages by zanecodes on Wednesday September 22, 2021 @01:20PM (#28619060)
One thing I've never understood is why stack traces don't, at a bare minimum, contain the values of the arguments passed to the function that threw the exception. That would be immensely helpful for reproducing the error.

Even better would be including the current values of any local variables introduced within the function, and any global variables referenced within the function.

Re:Long Error Messages by yongjik on Wednesday September 22, 2021 @01:27PM (#28619156)
That would require each argument be printable (i.e., has a function that prints its contents in a human-readable format), which is not always a given. Also, trying to print an object may cause another exception. (Imagine what will happen if you have a linked list, and a printer function that follows the links and print all nodes, but now the list is circular.)
Re:Long Error Messages by zanecodes on Wednesday September 22, 2021 @01:46PM (#28619403)
That's a good point. I would also like very much if languages included a sensible and useful default implementation of toString() or the equivalent for all types (e.g. print all the object's private & public property names & values, recursively, stopping if cycles are found).

Of course, this is probably only remotely feasible in languages that can guarantee that toString() won't have any side effects.

Re:Long Error Messages by gizmo686 on Wednesday September 22, 2021 @03:05PM (#28620367)
You need "side effects" to include memory allocation, seg faults, and "significant" amount of computation time (including never terminating). Worse, you need these properties when the program is known to be in an error state.

For a general purpose programming language this means that your toString cannot be a normal function.

Re:Long Error Messages by zanecodes on Wednesday September 22, 2021 @03:57PM (#28621034)
Also good points, I suppose the printing mechanism couldn't use the type's implementation of toString() and would instead have to use an implementation built into the runtime. Still, even being able to see just the raw bytes would be better than nothing in a lot of cases.
Re:Long Error Messages by robinson-wall on Wednesday September 22, 2021 @01:24PM (#28619108)
This could be very dangerous, depending where an exception happened. Variables can contain critical secrets, like your TLS keys or a user's password and if your stack trace printer isn't aware of what should be redacted now you've got that in your logs.
Re:Long Error Messages by zanecodes on Wednesday September 22, 2021 @01:40PM (#28619312)
Agreed, but this would help force developers to deal with treating secrets with the care they should have been treating them with all along, in my opinion.

PowerShell's [SecureString] type is something of a step in the right direction, although its execution is lacking in some respects.

In any case, stack traces should _always_ be treated as secrets.

Re:Long Error Messages by slaymaker1907 on Thursday September 23, 2021 @12:43AM (#28625279)
You can sort of do this by taking a dump of the thread/process. Just print out the location of the dump to the log (main downside being you need a debugger to analyze these files).
Re:Long Error Messages by Doxin on Friday September 24, 2021 @07:32AM (#28641010)
pytest stack traces include function arguments for select stack traces. It's stupendously convenient, but it does make the stack traces rather verbose at times.