Skip to content
Prev 23849 / 63424 Next

Problem using ofstream in C++ class in package for MacOS X

On Thu, Feb 08, 2007 at 10:04:14PM +0100, cstrato wrote:
Knowing the line isn't as specific as knowing exactly where it was
when it crashed.

Your stack trace was
Thread 0 Crashed:
0   libstdc++.6.dylib     0x020fe231 std::basic_ostream<char,
std::char_traits<char> >::flush() + 17 (ostream.tcc:395)
1   libstdc++.6.dylib     0x020fe358 std::basic_ostream<char,
std::char_traits<char>
 >::sentry::sentry[in-charge](std::basic_ostream<char,
std::char_traits<char> >&) + 120 (ostream.tcc:56)
2   libstdc++.6.dylib     0x02100b5d std::basic_ostream<char,
std::char_traits<char> >& std::operator<< <std::char_traits<char>
 >(std::basic_ostream<char, std::char_traits<char> >&, char const*) + 29
(ostream.tcc:620)
3   MyClass.so            0x0004a30f MyClassA::WriteFileCpp(char const*)
which doesn't look as if the problem is that << isn't recognized.
What is the thing that was at address 0x06?

The flush is probably from the endl.  If you traced it through, you
could tell if the first << completed.

Does
 output << endl;
work?
or
 output << "21";
or
 output << 21 << endl;
or
 #include <string>
 string s("21");
 output << s;
?

The different fates of the two OS-X platforms is certainly vexing.
These are all shots in the dark, but
1) Was the complete system (i.e., R as well as your code) built with
the the toolchain on both platforms?
2) Are your environments (e.g., environment variables) the same?
3) The recommended way to build stuff that will be talking to R is
with R CMD config.  Check first if that gives the same results on both
systems, and second if your build is using them.
4) Maybe some dylib (e.g., stdc++) is not getting initialized
properly.

Maybe there's some subtle linker problem, or a problem with the
representation of strings