Need some help debugging c++ code for 10.0
Tijl Coosemans
tijl at FreeBSD.org
Tue Oct 8 14:03:42 UTC 2013
On Tue, 08 Oct 2013 00:12:45 +1030 Shane Ambler wrote:
> Hi there, I am the port maintainer for opencolorio, openimageio and
> openshadinglanguage. These build and run on 9.2 with clang 3.3 but I
> have an issue on 10.0. I don't have much programming experience and even
> less with c++ which all 3 use.
>
> After ocio and oiio are installed building osl generates oslc (the osl
> script compiler) and then runs it to pre-compile the included scripts.
> This step fails on 10.0
>
> I am fairly sure that the issue is within the ustring class - full code
> can be viewed at github.com/OpenImageIO/oiio with src/include/ustring.h
> having some info about the class.
>
> The following is from src/libutil/ustring.cpp for ustrings constructor
>
> #if defined(__GNUC__)
> // We don't want the internal 'string str' to redundantly store the
> // chars, along with our own allocation. So we use our knowledge of
> // the internal structure of gcc strings to make it point to our chars!
> // Note that we've carefully structured the TableRep fields so they
> // mimic a GCC basic_string::_Rep.
> //
> // It turns out that the first field of a gcc std::string is a
> // pointer to the characters within the basic_string::_Rep. We
> // merely redirect that pointer, though for std::string to function
> // properly, the chars must be preceeded immediately in memory by
> // the rest of basic_string::_Rep, consisting of length, capacity
> // and refcount fields. And we have designed our TableRep to do
> // just that! So now we redirect the std::string's pointer to our
> // own characters and its mocked-up _Rep.
> //
> // See /usr/include/c++/VERSION/bits/basic_string.h for the details
> // of gcc's std::string implementation.
>
> *(const char **)&str = c_str();
> DASSERT (str.c_str() == c_str());
> #else
> // Not gcc -- just assign the internal string. This will result in
> // double allocation for the chars. If you care about that, do
> // something special for your platform, much like we did for gcc
> // above. (Windows users, I'm talking to you.)
> str = s;
> #endif
>
> When the osl build starts to precompile the bundled osl scripts oslc
> triggers the DASSERT (which is line 137) shown above. If I adjust the
> #if (and the matching destructor) so the non-gcc fallback is used, osl
> still fails just without the assert message.
There's a third __GNUC__ case in that header. Unlike the first two
it's ifNdef though so you need to change it into something like:
#if !defined(__GNUC__) || defined(_LIBCPP_VERSION)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20131008/938054cd/attachment.sig>
More information about the freebsd-ports
mailing list