Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ustring::string() returns empty string when using the new C++11 ABI #1174

Closed
foutrelis opened this issue Jun 26, 2015 · 2 comments
Closed

ustring::string() returns empty string when using the new C++11 ABI #1174

foutrelis opened this issue Jun 26, 2015 · 2 comments

Comments

@foutrelis
Copy link

I noticed that when using GCC 5.1 with the new libstdc++ ABI enabled, oslc foo.osl (from OpenShadingLanguage) would choose .oso as the output filename instead of foo.oso.

oslc uses shader_decl()->shadername().string() + ".oso" as the default output filename if one is not provided via the -o option. Further testing indicates that OpenImageIO's ustring::string() method is broken and returns an empty string on the new C++11 ABI.

Bellow is an example test program and GDB backtrace that show the issue.

#include <OpenImageIO/ustring.h>

int main(void) {
    auto a = OpenImageIO::v1_4::ustring("123");
    std::string b = "123";

    std::cout << "a = " << a.string() << std::endl << "b = " << b << std::endl;
    return 0;
}
Breakpoint 1, main () at test.cc:8
8       std::cout << "a = " << a.string() << std::endl << "b = " << b << std::endl;

(gdb) p a
$1 = {static npos = 18446744073709551615, m_chars = 0x61d870 "123", 
  static empty_std_string = <optimized out>}

(gdb) p a.string
$2 = {const std::__cxx11::string &(const OpenImageIO::v1_4::ustring * const)} 0x4010e6 <OpenImageIO::v1_4::ustring::string[abi:cxx11]() const>

(gdb) p &a.string()
$3 = (const std::__cxx11::string *) 0x61d838

(gdb) p a.string()
$4 = ""

(gdb) c
Continuing.
a = 
b = 123
lgritz added a commit to lgritz/OpenImageIO that referenced this issue Jun 26, 2015
This makes it work (and adds a test).
We still need to return and do something more clever for that case.
I'll need to install gcc 5.1 first to see how the internals work.
But in the mean time, at least this will unbreak things for people
already on gcc 5.1.

Fixes AcademySoftwareFoundation#1174
lgritz added a commit to lgritz/OpenImageIO that referenced this issue Jun 26, 2015
This makes it work (and adds a test).
We still need to return and do something more clever for that case.
I'll need to install gcc 5.1 first to see how the internals work.
But in the mean time, at least this will unbreak things for people
already on gcc 5.1.

Fixes AcademySoftwareFoundation#1174
@lgritz
Copy link
Collaborator

lgritz commented Jun 26, 2015

Can you test this workaround? #1176

@foutrelis
Copy link
Author

Seems to work, thanks!

Please note that most (if not all) Linux distros configure GCC 5.1 to use the old ABI (using --with-default-libstdcxx-abi=c++98). The issue won't manifest in such configurations, though building OIIO and its dependencies with -D_GLIBCXX_USE_CXX11_ABI=1 should be enough to reproduce it.

lgritz added a commit to lgritz/OpenImageIO that referenced this issue Jun 26, 2015
This makes it work (and adds a test).
We still need to return and do something more clever for that case.
I'll need to install gcc 5.1 first to see how the internals work.
But in the mean time, at least this will unbreak things for people
already on gcc 5.1.

Fixes AcademySoftwareFoundation#1174
SomeoneSerge pushed a commit to SomeoneSerge/arch-community-packages that referenced this issue Sep 4, 2016
AcademySoftwareFoundation/OpenImageIO#1174

git-svn-id: file:///srv/repos/svn-community/svn@135909 9fca08f4-af9d-4005-b8df-a31f2cc04f65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants