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

Runtime error of string memory allocating #2256

Closed
ivgotcrazy opened this issue Aug 7, 2023 · 4 comments
Closed

Runtime error of string memory allocating #2256

ivgotcrazy opened this issue Aug 7, 2023 · 4 comments
Assignees
Labels
bug Something isn't working triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@ivgotcrazy
Copy link

Describe your environment

Windows/C++17/Visual Studio

CMake parameters as below:
image

Steps to reproduce

simple code as below, just call the GetTracer method:

namespace trace = opentelemetry::trace;
typedef nostd::shared_ptrtrace::Tracer TracerNSP;

TracerNSP GetTracer(const std::string& tracer_name)
{
auto provider = trace::Provider::GetTracerProvider();
return provider->GetTracer(tracer_name, OPENTELEMETRY_SDK_VERSION);
}

What is the expected behavior?
Success

What is the actual behavior?

A runtime error was triggered:

image

ucrtbased.dll!00007fff30112e65()	Unknown
ucrtbased.dll!00007fff30113003()	Unknown
ucrtbased.dll!00007fff3012ab0d()	Unknown
ucrtbased.dll!00007fff30129a90()	Unknown
vcruntime140_1d.dll!00007fff4cfd223a()	Unknown
vcruntime140_1d.dll!00007fff4cfd2ec5()	Unknown
vcruntime140_1d.dll!00007fff4cfd2f57()	Unknown
vcruntime140_1d.dll!00007fff4cfd6ddb()	Unknown
tracer.dll!__GSHandlerCheck_EH4(_EXCEPTION_RECORD * ExceptionRecord, void * EstablisherFrame, _CONTEXT * ContextRecord, _DISPATCHER_CONTEXT * DispatcherContext) Line 73	C++
ntdll.dll!00007fff6f8923af()	Unknown
ntdll.dll!00007fff6f8414b4()	Unknown
ntdll.dll!00007fff6f890ebe()	Unknown
KernelBase.dll!00007fff6d1acf19()	Unknown
vcruntime140d.dll!00007fff3762b760()	Unknown
tracer.dll!__scrt_throw_std_bad_alloc() Line 36	C++
tracer.dll!operator new(unsigned __int64 size) Line 53	C++
tracer.dll!std::_Default_allocate_traits::_Allocate(const unsigned __int64 _Bytes) Line 78	C++
tracer.dll!std::_Allocate_manually_vector_aligned<std::_Default_allocate_traits>(const unsigned __int64 _Bytes) Line 134	C++
tracer.dll!std::_Allocate<16,std::_Default_allocate_traits,0>(const unsigned __int64 _Bytes) Line 229	C++
tracer.dll!std::allocator<char>::allocate(const unsigned __int64 _Count) Line 835	C++
tracer.dll!std::string::_Construct<1,char const *>(const char * const _Arg, const unsigned __int64 _Count) Line 2771	C++
tracer.dll!std::string::basic_string<char,std::char_traits<char>,std::allocator<char>><std::basic_string_view<char,std::char_traits<char>>,0>(const std::basic_string_view<char,std::char_traits<char>> & _Right, const std::allocator<char> & _Al) Line 3026	C++

tracer.dll!opentelemetry::v1::sdk::instrumentationscope::InstrumentationScope::InstrumentationScope(std::basic_string_view<char,std::char_traits> name, std::basic_string_view<char,std::char_traits> version, std::basic_string_view<char,std::char_traits> schema_url, opentelemetry::v1::sdk::common::AttributeMap && attributes) Line 140 C++
tracer.dll!opentelemetry::v1::sdk::instrumentationscope::InstrumentationScope::Create(std::basic_string_view<char,std::char_traits> name, std::basic_string_view<char,std::char_traits> version, std::basic_string_view<char,std::char_traits> schema_url, opentelemetry::v1::sdk::common::AttributeMap && attributes) Line 44 C++
tracer.dll!opentelemetry::v1::sdk::trace::TracerProvider::GetTracer(std::basic_string_view<char,std::char_traits> library_name, std::basic_string_view<char,std::char_traits> library_version, std::basic_string_view<char,std::char_traits> schema_url) Line 82 C++
tracer.dll!`anonymous namespace'::GetTracer(const std::string & tracer_name) Line 43 C++
tracer.dll!jukey::com::TraceMgr::StartSpan(const std::string & span_name) Line 144 C++
test-tracer.exe!main(int argc, char * * argv) Line 33 C++
[External Code]

Additional context
image

@ivgotcrazy ivgotcrazy added the bug Something isn't working label Aug 7, 2023
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Aug 7, 2023
@ThomsonTan ThomsonTan self-assigned this Aug 9, 2023
@ivgotcrazy
Copy link
Author

This problem has been bothering me for a long time. It looks like a binary compatibility issue. Do I need to set a certain compilation option? Does anybody has good ideas or suggestions?

@ThomsonTan
Copy link
Contributor

@ivgotcrazy is this still valid? If yes, is it possible to share the dump file and .pdb files for the related component?

@marcalff marcalff added triage/needs-information Indicates an issue needs more information in order to work on it. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 11, 2023
@marcalff
Copy link
Member

A possible reason to have binary compatibility issues is related to:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")

opentelemetry-cpp sets this flag when building the library.

An application compiling with the opentelemetry-cpp header files also needs to set this flag.

When not set, the build will contain C++98 code compiled in the application, linked with C++11/14/17/20/23 code depending on the compiler used, when linking the SDK.

Mixing different implementations is likely to produce a corrupt binary, leading to crashes.

@marcalff
Copy link
Member

Closing.

Binary compatibility issue is suspected to be caused by missing option /Zc:__cplusplus in Visual Studio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

3 participants