[MacPorts] #36204: gcc47 empty string issue
MacPorts
noreply at macports.org
Tue Sep 18 06:49:05 PDT 2012
#36204: gcc47 empty string issue
-------------------------+--------------------------------
Reporter: rob.patro@… | Owner: macports-tickets@…
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.1.2
Keywords: | Port:
-------------------------+--------------------------------
I'm trying to use the Boost iostream library in OSX with gcc 4.7 (since
I'll be using C++11 features). The following code compiles and links, but
fails at runtime:
{{{
#include <iostream>
#include <fstream>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
int main(int argc, char** argv) {
std::string fname(argv[1]);
std::ifstream file(fname.c_str(), std::ios_base::in |
std::ios_base::binary);
try {
boost::iostreams::filtering_istream in;
in.push(boost::iostreams::gzip_decompressor());
in.push(boost::iostreams::file_source(fname));
for( std::string str; std::getline(in, str); ) {
std::cout << "Processed line " << str << '\n';
}
}
catch(const boost::iostreams::gzip_error& e) {
std::cout << e.what() << '\n';
}
}
}}}
With the following error:
{{{
test(70632) malloc: *** error for object 0x100168860: pointer being freed
was not allocated
*** set a breakpoint in malloc_error_break to debug
}}}
Running this under GDB, the stackframe is the following
{{{
Program received signal SIGABRT, Aborted.
0x00007fff8b0d0d46 in __kill ()
(gdb) bt
#0 0x00007fff8b0d0d46 in __kill ()
#1 0x00007fff88f52e1c in abort ()
#2 0x00007fff88f26989 in free ()
#3 0x00007fff84365e7c in std::string::reserve ()
#4 0x00007fff8436606e in std::string::push_back ()
#5 0x00007fff8436602d in std::string::operator+= ()
#6 0x000000010006f307 in boost::iostreams::detail::gzip_header::process
(this=0x113e8, c=6 '\006') at gzip.cpp:100
#7 0x000000010000f435 in
boost::iostreams::basic_gzip_decompressor<std::allocator<char>
>::read<boost::iostreams::detail::linked_streambuf<char,
std::char_traits<char> > > ()
#8 0x000000010000f13e in
boost::iostreams::detail::read_filter_impl<boost::iostreams::multichar_tag>::read<boost::iostreams::basic_gzip_decompressor<std::allocator<char>
>, boost::iostreams::detail::linked_streambuf<char, std::char_traits<char>
> > ()
#9 0x000000010000edd7 in
boost::iostreams::read<boost::iostreams::basic_gzip_decompressor<std::allocator<char>
>, boost::iostreams::detail::linked_streambuf<char, std::char_traits<char>
> > ()
#10 0x000000010000e557 in
boost::iostreams::detail::flt_wrapper_impl<boost::iostreams::input>::read<boost::iostreams::basic_gzip_decompressor<std::allocator<char>
>, boost::iostreams::detail::linked_streambuf<char, std::char_traits<char>
> > ()
#11 0x000000010000e1d8 in
boost::iostreams::detail::concept_adapter<boost::iostreams::basic_gzip_decompressor<std::allocator<char>
> >::read<boost::iostreams::detail::linked_streambuf<char,
std::char_traits<char> > > ()
#12 0x000000010000d020 in
boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_decompressor<std::allocator<char>
>, std::char_traits<char>, std::allocator<char>,
boost::iostreams::input>::underflow ()
#13 0x00000001000be63a in std::getline<char, std::char_traits<char>,
std::allocator<char> > ()
}}}
I filed this under gcc instead of boost because it looks like the problem
goes down to some
very fundamental std::string code, and I assume boost isn't to blame here.
It also leads me to
believe this error might be encountered far outside this test case.
--
Ticket URL: <https://trac.macports.org/ticket/36204>
MacPorts <http://www.macports.org/>
Ports system for Mac OS
More information about the macports-tickets
mailing list