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

Unhandled exception when running "compiled-in" example code on Windows #170

Closed
brotherpboon opened this issue Apr 2, 2021 · 5 comments
Closed

Comments

@brotherpboon
Copy link

Hi. I'm trying to run the compiled-in example on a local Windows machine. I am getting an unhandled exception on line 91 file tracer_options.cpp (see attached image and code below). Please advise.

Here is my code:

#include <datadog/opentracing.h>
#include <datadog/tags.h>
#include <iostream>
#include <string>

int main()
{
	datadog::opentracing::TracerOptions tracer_options{ "localhost", 8126, "compiled-in example" };
	auto tracer = datadog::opentracing::makeTracer(tracer_options);  <=== this line leads to exception

	// Create some spans.
	{
		auto span_a = tracer->StartSpan("A");
		span_a->SetTag(datadog::tags::environment, "production");
		span_a->SetTag("tag", 123);
		auto span_b = tracer->StartSpan("B", { opentracing::ChildOf(&span_a->context()) });
		span_b->SetTag("tag", "value");
	}

	tracer->Close();
    std::cout << "Hello World!\n";
}

=====================================================================

exception

ot::expected<TracerOptions, const char *> applyTracerOptionsFromEnvironment(
    const TracerOptions &input) {
  TracerOptions opts = input;   <===== this line causes the exception

  auto environment = std::getenv("DD_ENV");
  if (environment != nullptr && std::strlen(environment) > 0) {
    opts.environment = environment;
  }

  auto service = std::getenv("DD_SERVICE");
  if (service != nullptr && std::strlen(service) > 0) {
    opts.service = service;
  }
@brotherpboon
Copy link
Author

This runtime exception only occurs in debug build. I am able to run release without any issue.

@cgilmour
Copy link
Contributor

cgilmour commented Apr 7, 2021

Thanks for reporting this @brotherpboon, and good to know it works as-expected for release builds.
It took a few attempts and some user-error, but your clue about debug builds has helped me to reproduce this.

Not yet sure what I can do to fix it. The code it is failing on is fairly ordinary, no hidden magic to it.

@brotherpboon
Copy link
Author

I was able to get it to run under debug code if I rebuild and set the configuration to Debug instead of RelWithDebInfo

cmake --build . -- -p:Configuration=Debug

Then I had to change the dependencies' names accordingly under Project properties->Linker->Input.

For example:

libcurl.lib to libcurl-d.lib
zlib.lib to zlibd.lib

I am now able to send traces to DD running under both debug and release configurations.

@cgilmour
Copy link
Contributor

cgilmour commented Apr 8, 2021

Thanks for the update @brotherpboon and confirming the issue was from mixing debug and release builds for libraries and an approach to avoid it.

@dgoffredo
Copy link
Contributor

I've created #198 to make note of this potential issue in our Windows build instructions.

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

3 participants