Re: [PATCH] makedumpfile tries to output infinite ETA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



makedumpfile-1.6.3

At the beginning of writing the dumpfile, print_progress can attempt
to output a progress line like

Copying data                    : [  0.0 %] -  eta: -2147483648s

This happens because the ETA can evaluate as infinity when there has
not yet been any progress: the number it is trying to output is the
result of casting an infinite float to an int, which is undefined,
i.e., compiler-dependent. Where it has not been possible to calculate
a sensible ETA, no attempt should be made to output one.

More seriously in this case, combined with "eta: ", this length
exceeds the remaining characters of the buffer into which it is
writing (eta_msg).

This code executes even if the progress output is disabled, so there
is no workaround not involving a code change.

(While not an immediate issue, there are also some type discrepancies,
e.g., print_progress takes unsigned longs but is passed mdf_pfn_t
which is unsigned long long.)

A minimal, tested fix is:

--- makedumpfile-1.6.3.org/print_info.c    2018-01-26 01:30:25.000000000 +0000
+++ makedumpfile-1.6.3/print_info.c    2018-06-11 14:44:48.111182518 +0100
@@ -16,6 +16,7 @@
 #include "print_info.h"
 #include <time.h>
 #include <string.h>
+#include <math.h>

 #define PROGRESS_MAXLEN        "50"

@@ -395,7 +396,8 @@ print_progress(const char *msg, unsigned
         calc_delta(start, &delta);
         eta = delta.tv_sec + delta.tv_usec / 1e6;
         eta = (100 - progress) * eta / progress;
-        eta_to_human_short(eta, eta_msg);
+        if (isfinite(eta))
+            eta_to_human_short(eta, eta_msg);
     }
     if (flag_ignore_r_char) {
         PROGRESS_MSG("%-" PROGRESS_MAXLEN "s: [%5.1f %%] %c  %16s\n",

-- 
CONFIDENTIALITY
This e-mail message and any attachments thereto, is 
intended only for use by the addressee(s) named herein and may contain 
legally privileged and/or confidential information. If you are not the 
intended recipient of this e-mail message, you are hereby notified that any 
dissemination, distribution or copying of this e-mail message, and any 
attachments thereto, is strictly prohibited. If you have received this 
e-mail message in error, please immediately notify the sender and 
permanently delete the original and any copies of this email and any prints 
thereof.
ABSENT AN EXPRESS STATEMENT TO THE CONTRARY HEREINABOVE, THIS 
E-MAIL IS NOT INTENDED AS A SUBSTITUTE FOR A WRITING. Notwithstanding the 
Uniform Electronic Transactions Act or the applicability of any other law 
of similar substance and effect, absent an express statement to the 
contrary hereinabove, this e-mail message its contents, and any attachments 
hereto are not intended to represent an offer or acceptance to enter into a 
contract and are not otherwise intended to bind the sender, MPSTOR, or any 
other person or entity.

_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux