[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    [kcalc] [Bug 337394] kcalc crashes left shifting a large number
From:       Evan Teran <eteran () alum ! rit ! edu>
Date:       2014-07-17 2:45:35
Message-ID: bug-337394-17878-6jVoN7Hijw () http ! bugs ! kde ! org/
[Download RAW message or body]

https://bugs.kde.org/show_bug.cgi?id=337394

Evan Teran <eteran@alum.rit.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |CONFIRMED
     Ever confirmed|0                           |1

--- Comment #1 from Evan Teran <eteran@alum.rit.edu> ---
Thank you for the bug report. This does appear to be a real issue, though your
fix does not seem to be correct. sizeof(KNumber) is not really a sensical
operation as it is taking the size of a c++ object (which just wraps a pointer
to an abstract class. KNumber is not simply a typedef to something like a "long
double", but it is actually an implementation of an infinite (well limited by
ram) precision math library.

So, if KNumber is infinite precision, then what's the real problem?

When you click the shift operator twice, essentially you are asking kcalc to
shift the value by itself. For example:

x << << =

is the same as:

x << x =

Since this is an arbitrary precision calculator. That operation is the same as:

x = x * pow(2, x);

as you can imagine, for a sufficiently large number. The result will easily be
a number that will simply not fit in RAM... thus a crash when it tries to
allocate space for it.

I will investigate the ideal solution for this issue. Thank you for the report.

-- 
You are receiving this mail because:
You are watching all bug changes.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic