Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10057

Recent change to streaming of doubles in QDataStream can cause floating point exceptions

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.0
    • 4.7.0
    • Core: I/O
    • None
    • Windows
    • c9a5b8f0d840e67ad33839c8c310aef73a8a855c

    Description

      In the debug build of our application, we enable (most) floating point exceptions, as these have helped us catch bugs in third-party components in the past. With the 4.7 tech preview however, QDataStream can now cause floating point exceptions when streaming out doubles, which makes our debug build unusable unless these exceptions are masked.

      The problem is that the double is byteswapped using a union with a quint64, then re-assigned to a double. By this stage the double is likely to be in an odd state - in my example it's a denormal number, which raises the exception. Build and run the attached test to illustrate the bug (Windows only).

      This change was introduced here: http://qt.gitorious.org/qt/qt/merge_requests/1706. See QDataStream::operator<<(double f). The offending line is the cast back to double with f = x.val1.

      I've patched this in our Qt repository - see attached. This is slightly less neat, but safer in environments where floating point exceptions are enabled.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tmacieir Thiago Macieira (closed Nokia identity) (Inactive)
            jlarcombe James Larcombe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes