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

libstdc++ span not ABI compatible with nostd::span since GCC 11 #1705

Closed
johanpel opened this issue Oct 21, 2022 · 3 comments · Fixed by #1731
Closed

libstdc++ span not ABI compatible with nostd::span since GCC 11 #1705

johanpel opened this issue Oct 21, 2022 · 3 comments · Fixed by #1731
Assignees
Labels
bug Something isn't working

Comments

@johanpel
Copy link
Contributor

johanpel commented Oct 21, 2022

I was debugging some segfaults that occurred when I was building the OTel libraries with WITH_STL=ON, statically linking them to an application. I wasn't using an explicit CMAKE_CXX_STANDARD for OTel which caused it to build with C++20, while the application is built with C++17. This caused a segfault in the InMemorySpanExporter as that was using a different implementation of nostd::span because its included through a header-only file.

The solution was to just explicitly set the same CMAKE_CXX_STANDARD for the OTel build so the same nostd::span implementation is selected, but I did notice the following.

There is a comment here hinting that it is desirable to have ABI compatibility with libstdc++'s implementation of std::span:
https://github.com/open-telemetry/opentelemetry-cpp/blob/main/api/include/opentelemetry/nostd/span.h#L243-L247

However, that implementation has since GCC 11 swapped around the extent and data fields:
https://github.com/gcc-mirror/gcc/blob/releases/gcc-11.3.0/libstdc++-v3/include/std/span#L392-L393

This was causing my segfaults.

Of course my problem was fixed by properly setting the CMAKE_CXX_STANDARD for OTel the same as my application, but I just wanted to mention that here in case this has any implications I am not aware of.

@johanpel johanpel added the bug Something isn't working label Oct 21, 2022
@lalitb
Copy link
Member

lalitb commented Oct 21, 2022

Option to build with Standard library is only provided for environment where ABI compatibility is not required. No ABI compatibility is guaranteed between nostd implementations and standard library - https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/building-with-stdlib.md

@johanpel
Copy link
Contributor Author

No ABI compatibility is guaranteed between nostd implementations and standard library.

Understood. Perhaps the title of this issue is a bit misleading of my intentions, but it's mainly about the comment in the code. Feel free to close this if that comment should not be updated.

@marcalff
Copy link
Member

marcalff commented Nov 2, 2022

No ABI compatibility is guaranteed between nostd implementations and standard library.

Understood. Perhaps the title of this issue is a bit misleading of my intentions, but it's mainly about the comment in the code. Feel free to close this if that comment should not be updated.

@johanpel

Thanks for the detailed investigations.

The comment is indeed misleading, and should be removed.

marcalff added a commit to marcalff/opentelemetry-cpp that referenced this issue Nov 2, 2022
@marcalff marcalff self-assigned this Nov 2, 2022
@lalitb lalitb closed this as completed in 7812651 Nov 4, 2022
yxue pushed a commit to yxue/opentelemetry-cpp that referenced this issue Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants