[Bug debug/107965] libstdc++ Python Pretty-Printers: Many Exceptions From Uninitialized Structures
gustaf.waldemarson at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jan 17 19:37:01 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107965
--- Comment #7 from Gustaf Waldemarson <gustaf.waldemarson at gmail dot com> ---
Very interesting to see so many people chime in on this. Since I arguably
agree that this looks like a GDB bug than an error in the printers. To that
end, I went ahead and registered this
[ticket](https://sourceware.org/bugzilla/show_bug.cgi?id=30018) here. Please
feel free to add
some more details if you have time, as some of the details presented here is
admittedly a bit beyond my skills.
All that said, I still think that the pretty printers should be a bit more
defensive to errors and conservative with what it outputs. E.g., presenting an
error message once, due to something like this is fine in my opinion, but
displaying hundreds of lines with the same error just because some function
uses a hash-map is clearly excessive.
To that end, perhaps it would make sense to defend the `to_string` calls (and
possibly others) with something like this:
seen_errors = {}
# ...
try:
to_string(...)
except Exception as ex:
if ex not in seen_errors:
seen_errors.add(ex)
raise ex
Admittedly, I don't know all the details here, so perhaps this isn't feasible?
More information about the Gcc-bugs
mailing list