bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/25244] New: --print-memory-usage, division by zero if MEMORY len


From: pexu at sourceware dot mail.kapsi.fi
Subject: [Bug ld/25244] New: --print-memory-usage, division by zero if MEMORY length is zero
Date: Tue, 03 Dec 2019 14:55:53 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=25244

            Bug ID: 25244
           Summary: --print-memory-usage, division by zero if MEMORY
                    length is zero
           Product: binutils
           Version: 2.34 (HEAD)
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: pexu at sourceware dot mail.kapsi.fi
  Target Milestone: ---

Hi.

lang_print_memory_usage() at ld/ldlang.c calculates and displays the memory
region usage as follows:

9282       percent = used_length * 100.0 / r->length;
9284       printf ("    %6.2f%%\n", percent);

If the memory region length is zero (denoted by r->length), this will cause
division by zero.  Likely no other harm is done, except not all printf
implementations adhere to e.g. IEEE 1003.1 (POSIX specifications), causing some
implementation specific format to be shown when a NaN is passed (or -NaN, given
that the floating point implementation behaves as such).

E.g. MinGW targets (as they use MS Visual C library) display `[-]1.#J'
(`[-]1#IND' truncated to %6.2f).  This might cause issues if a tool that uses
the output data does not except this kind of behaviour (wouldn't call this
undefined by any means).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]