<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>134070</bug_id>
          
          <creation_ts>2006-09-14 16:20:05 +0000</creation_ts>
          <short_desc>crash on large result, &quot;exp&quot; operation</short_desc>
          <delta_ts>2006-09-23 01:21:34 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>kcalc</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>Gentoo Packages</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>crash</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ernst Bachmann">ebachmann</reporter>
          <assigned_to name="Klaus Niederkrüger">kniederk</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>469888</commentid>
    <comment_count>0</comment_count>
    <who name="Ernst Bachmann">ebachmann</who>
    <bug_when>2006-09-14 16:20:05 +0000</bug_when>
    <thetext>Version:           2.0.4 (using KDE KDE 3.5.4)
Installed from:    Gentoo Packages
Compiler:          gcc-4.1.1 
OS:                Linux

enter a large number (say 1000), then hit &quot;Inv&quot;, then &quot;e^x&quot; =&gt; Kcalc crashes.

according to GDB the crash occurs in:
#0  0x000000354b90cbd9 in raise () from /lib/libpthread.so.0
#1  0x000000370ea07d0e in __gmp_invalid_operation () from /usr/lib64/libgmp.so.3
#2  0x000000370ea09aed in __gmpf_set_d () from /usr/lib64/libgmp.so.3
#3  0x0000003478158d8c in KNumber::KNumber () from /usr/kde/3.5/lib64/libkdeinit_kcalc.so
#4  0x000000347813c2be in CalcEngine::Exp () from /usr/kde/3.5/lib64/libkdeinit_kcalc.so
#5  0x000000347814abdb in KCalculator::slotLnclicked () from /usr/kde/3.5/lib64/libkdeinit_kcalc.so

Seems like its not generally a problem with the result value, as kcalc can calculate e.g. 10^1000000 just fine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>470097</commentid>
    <comment_count>1</comment_count>
    <who name="Philip Rodrigues">phil</who>
    <bug_when>2006-09-15 13:26:47 +0000</bug_when>
    <thetext>Confirmed. Different backtrace though:

#12 0x29460b6c in sigaction () from /usr/lib/libpthread.so.2
#13 0x2952db23 in abort () from /lib/libc.so.6
#14 0x2984dc2f in __gmp_invalid_operation () from /usr/local/lib/libgmp.so.7
#15 0x2984f513 in __gmpf_set_d () from /usr/local/lib/libgmp.so.7
#16 0x2983b28a in _knumfloat (this=0x8245fb8, num=inf) at knumber_priv.h:270
#17 0x298382ea in KNumber (this=0xbfbfdb80, num=inf)
    at /home/phil/kdesrc/kdeutils/kcalc/knumber/knumber.cpp:72
#18 0x29824630 in CalcEngine::Exp (this=0x8168c88, input=
      {static Zero = {static Zero = &lt;same as static member of an already seen type&gt;, static One = {static Zero = &lt;same as static member of an already seen type&gt;, static One = &lt;same as static member of an already seen type&gt;, static MinusOne = {static Zero = &lt;same as static member of an already seen type&gt;, static One = &lt;same as static member of an already seen type&gt;, static MinusOne = &lt;same as static member of an already seen type&gt;, static Pi = {static Zero = &lt;same as static member of an already seen type&gt;, static One = &lt;same as static member of an already seen type&gt;, static MinusOne = &lt;same as static member of an already seen type&gt;, static Pi = &lt;same as static member of an already seen type&gt;, static Euler = {static Zero = &lt;same as static member of an already seen type&gt;, static One = &lt;same as static member of an already seen type&gt;, static MinusOne = &lt;same as static member of an already seen type&gt;, static Pi = &lt;same as static member of an already seen type&gt;, static Euler = &lt;same as static member of an already seen type&gt;, _num = 0x80e3a38, static _float_output = true, static _fraction_input = true, static _splitoffinteger_output = false}, _num = 0x80d0938, static _float_output = true, static _fraction_input = true, static _splitoffinteger_output = false}, static Euler = &lt;same as static member of an already seen type&gt;, _num = 0x80d4fe0, static _float_output = true, static _fraction_input = true, static _splitoffinteger_output = false}, static Pi = &lt;same as static member of an already seen type&gt;, static Euler = &lt;same as static member of an already seen type&gt;, _num = 0x80d0e18, static _float_output = true, static _fraction_input = true, static _splitoffinteger_output = false}, static MinusOne = &lt;same as static member of an already seen type&gt;, static Pi = &lt;same as static member of an already seen type&gt;, static Euler = &lt;same as static member of an already seen type&gt;, _num = 0x80d0b68, static _float_output = true, static _fraction_input = true, static _splitoffinteger_output = false}, static One = &lt;same as static member of an already seen type&gt;, static MinusOne = &lt;same as static member of an already seen type&gt;, static Pi = &lt;same as static member of an already seen type&gt;, static Euler = &lt;same as static member of an already seen type&gt;, _num = 0x82385b0, static _float_output = true, static _fraction_input = true, static _splitoffinteger_output = false}) at /home/phil/kdesrc/kdeutils/kcalc/kcalc_core.cpp:574
#19 0x298168b3 in KCalculator::slotLnclicked (this=0x8168a18)
    at /home/phil/kdesrc/kdeutils/kcalc/kcalc.cpp:1517
#20 0x2981a6a9 in KCalculator::qt_invoke (this=0x8168a18, _id=99, 
    _o=0xbfbfdcc0) at kcalc.moc:333
#21 0x28e141e0 in QObject::activate_signal ()
   from /usr/X11R6/lib/libqt-mt.so.3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>470099</commentid>
    <comment_count>2</comment_count>
    <who name="Ernst Bachmann">ebachmann</who>
    <bug_when>2006-09-15 13:44:00 +0000</bug_when>
    <thetext>Well, besides the differences caused by 64bit/32bit arch, different library versions, and my version coming from a strip&apos;ed binary, they look quite similar to me.

Basically it looks like libgmp is trying to calculate the result, gets an overflow, and raises a SIGFPE signal, which isn&apos;t handled.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>470398</commentid>
    <comment_count>3</comment_count>
    <who name="Philip Rodrigues">phil</who>
    <bug_when>2006-09-16 20:42:44 +0000</bug_when>
    <thetext>Ah yes, good point. Should&apos;ve looked more carefully</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>470676</commentid>
    <comment_count>4</comment_count>
      <attachid>17816</attachid>
    <who name="Philip Rodrigues">phil</who>
    <bug_when>2006-09-17 23:15:29 +0000</bug_when>
    <thetext>Created attachment 17816
Suggested fix

Change the KNumber initialization to check for NaN and Inf, since passing these
to libgmp causes a crash. Does this also need to be done for other types?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>471059</commentid>
    <comment_count>5</comment_count>
    <who name="Klaus Niederkrüger">kniederk</who>
    <bug_when>2006-09-19 11:48:34 +0000</bug_when>
    <thetext>Good idea (the patch).

I try to apply this as soon as I have time.

Klaus</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>472087</commentid>
    <comment_count>6</comment_count>
    <who name="Klaus Niederkrüger">kniederk</who>
    <bug_when>2006-09-23 01:21:34 +0000</bug_when>
    <thetext>Applied your patch. Thanks a lot

Klaus</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>17816</attachid>
            <date>2006-09-17 23:15:29 +0000</date>
            <delta_ts>2006-09-17 23:15:29 +0000</delta_ts>
            <desc>Suggested fix</desc>
            <filename>kcalc.diff</filename>
            <type>text/plain</type>
            <size>493</size>
            <attacher name="Philip Rodrigues">phil</attacher>
            
              <data encoding="base64">SW5kZXg6IGtudW1iZXIva251bWJlci5jcHAKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0ga251bWJlci9rbnVtYmVy
LmNwcAkocmV2aXNpb24gNTgyMTgzKQorKysga251bWJlci9rbnVtYmVyLmNwcAkod29ya2luZyBj
b3B5KQpAQCAtNjksNyArNjksMTAgQEAKIAogS051bWJlcjo6S051bWJlcihkb3VibGUgbnVtKQog
ewotICBfbnVtID0gbmV3IF9rbnVtZmxvYXQobnVtKTsKKyAgaWYgKCBpc2luZihudW0pICkgX251
bSA9IG5ldyBfa251bWVycm9yKCBfa251bWJlcjo6SW5maW5pdHkgKTsKKyAgZWxzZSBpZiAoIGlz
bmFuKG51bSkgKSBfbnVtID0gbmV3IF9rbnVtZXJyb3IoIF9rbnVtYmVyOjpVbmRlZmluZWROdW1i
ZXIgKTsKKyAgZWxzZSBfbnVtID0gbmV3IF9rbnVtZmxvYXQobnVtKTsgICAgICAKKwogfQogCiBL
TnVtYmVyOjpLTnVtYmVyKEtOdW1iZXIgY29uc3QgJiBudW0pCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>