* [PATCH] abg-dwarf-reader.cc: Avoid division by zero.
@ 2020-03-30 16:40 Giuliano Procida
2020-04-01 17:45 ` Dodji Seketeli
0 siblings, 1 reply; 2+ messages in thread
From: Giuliano Procida @ 2020-03-30 16:40 UTC (permalink / raw)
To: libabigail; +Cc: dodji, kernel-team, gprocida
The DWARF reader could divide by zero when emitting statistics about
late canonicalisation of types. This is undefined behaviour but
typically results in process termination.
* src/abg-dwarf-reader.cc (perform_late_type_canonicalizing):
If total is zero, don't try to output percentages using it as
a divisor.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
src/abg-dwarf-reader.cc | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 10ca1232..249e196d 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -5849,11 +5849,15 @@ public:
<< elf_path()
<< "\n";
cerr << " # late canonicalized types: "
- << num_canonicalized
- << " (" << num_canonicalized * 100 / total << "%)\n"
+ << num_canonicalized;
+ if (total)
+ cerr << " (" << num_canonicalized * 100 / total << "%)";
+ cerr << "\n"
<< " # missed canonicalization opportunities: "
- << num_missed
- << " (" << num_missed * 100 / total << "%)\n";
+ << num_missed;
+ if (total)
+ cerr << " (" << num_missed * 100 / total << "%)";
+ cerr << "\n";
}
}
--
2.26.0.rc2.310.g2932bb562d-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] abg-dwarf-reader.cc: Avoid division by zero.
2020-03-30 16:40 [PATCH] abg-dwarf-reader.cc: Avoid division by zero Giuliano Procida
@ 2020-04-01 17:45 ` Dodji Seketeli
0 siblings, 0 replies; 2+ messages in thread
From: Dodji Seketeli @ 2020-04-01 17:45 UTC (permalink / raw)
To: Giuliano Procida; +Cc: libabigail, kernel-team
Giuliano Procida <gprocida@google.com> a écrit:
> The DWARF reader could divide by zero when emitting statistics about
> late canonicalisation of types. This is undefined behaviour but
> typically results in process termination.
>
> * src/abg-dwarf-reader.cc (perform_late_type_canonicalizing):
> If total is zero, don't try to output percentages using it as
> a divisor.
Applied to master, thanks!
Cheers,
--
Dodji
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-01 17:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 16:40 [PATCH] abg-dwarf-reader.cc: Avoid division by zero Giuliano Procida
2020-04-01 17:45 ` Dodji Seketeli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).