Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jan 2012 16:32:09 GMT
From:      Shane Ambler <FreeBSD@Shaneware.biz>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/164144: Crash on sending float/double values to std::ostringstream
Message-ID:  <201201151632.q0FGW96B010738@red.freebsd.org>
Resent-Message-ID: <201201151640.q0FGeABo097134@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         164144
>Category:       misc
>Synopsis:       Crash on sending float/double values to std::ostringstream
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 15 16:40:09 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Shane Ambler
>Release:        9.0-RELEASE
>Organization:
>Environment:
FreeBSD leader 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
In c++ code sending a float or double value to a std::ostringstream using a << operator causes an illegal instruction. Sending a long double in the same place works.

I find clang++ g++ and g++46 produce the same results so expect this is within libc++.

This bug was found running blender - it is used within the elbeem lib code for fluid sims.

Within gdb the following example code gives -

For float values --
Program received signal SIGILL, Illegal instruction.
0x00000008008e0060 in std::ostream::operator<< (this=0x7fffffffd2c0, __f=100.255997) at ostream.tcc:221
221	ostream.tcc: No such file or directory.
	in ostream.tcc
Current language:  auto; currently c++

For double values --
Program received signal SIGILL, Illegal instruction.
0x00000008008dfe6b in std::ostream::_M_insert<double> (this=0x7fffffffd2c0, __v=100.256) at ostream.tcc:221
221	ostream.tcc: No such file or directory.
	in ostream.tcc
Current language:  auto; currently c++

>How-To-Repeat:
Build the following - clang++ test.cpp - and run

#include <sstream>

int main(int argc, char ** argv)
{
    std::ostringstream testout;

    // broken
    testout << (float)100.256;

    // broken
    testout << (double)100.256;

    // works
    testout << (long double)100.256;

    // exit nicely if we get here
    return 0;
}

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201151632.q0FGW96B010738>