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

AccessViolation when running auto-instrumentation from nuget package #3567

Closed
cabadam opened this issue Aug 13, 2024 · 3 comments
Closed

AccessViolation when running auto-instrumentation from nuget package #3567

cabadam opened this issue Aug 13, 2024 · 3 comments
Assignees
Milestone

Comments

@cabadam
Copy link

cabadam commented Aug 13, 2024

Bug Report

Symptom

Describe the bug
I followed the instructions here: https://opentelemetry.io/docs/zero-code/net/nuget-packages/

When I run instrument.cmd .\OpenTelemetryAutoWorker.exe, an exception is logged:

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:

at OpenTelemetry.AutoInstrumentation.NativeMethods+Windows.AddInstrumentations(System.String, OpenTelemetry.AutoInstrumentation.NativeCallTargetDefinition[], Int32)

at OpenTelemetry.AutoInstrumentation.NativeMethods.AddInstrumentations(System.String, OpenTelemetry.AutoInstrumentation.NativeCallTargetDefinition[])
at OpenTelemetry.AutoInstrumentation.Instrumentation.RegisterBytecodeInstrumentations(Payload)
at OpenTelemetry.AutoInstrumentation.Instrumentation.Initialize()
at System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(System.Object, System.Reflection.BindingFlags)
at System.Reflection.MethodBase.Invoke(System.Object, System.Object[])
at OpenTelemetry.AutoInstrumentation.Loader.Loader.TryLoadManagedAssembly()
at OpenTelemetry.AutoInstrumentation.Loader.Loader..cctor()
at OpenTelemetry.AutoInstrumentation.Loader.Loader..ctor()
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean, Boolean)
at System.RuntimeType.CreateInstanceImpl(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
at System.Reflection.Assembly.CreateInstance(System.String)
at StartupHook.Initialize()
at System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(System.Object, System.Reflection.BindingFlags)
at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath)
at System.StartupHookProvider.ProcessStartupHooks(System.String)

Expected behavior
The application launches and runs.

Runtime environment (please complete the following information):

  • OpenTelemetry Automatic Instrumentation version: 1.7.0
  • OS: Windows 11
  • .NET version: .NET 8.0

Reproduce

A sample application that demonstrates the issue is here: A sample application that demonstrates the issue is here: https://github.com/cabadam/OpenTelemetryAutoWorker

Steps to reproduce the behavior:

  1. Create a new application using the Worker Service template.
  2. Add a Nuget reference to OpenTelemetry.AutoInstrumentation.
  3. Build the solution (it should succeed).
  4. Execute the instrumentation command on the compiled executable.

Logs attached:
logs.zip

@lachmatt
Copy link
Contributor

lachmatt commented Aug 13, 2024

I'm able to reproduce if app is built/published without specifying runtime identifier.

@lachmatt
Copy link
Contributor

Scripts were expected to be run from the output of build/publish with runtime identifier specified.
Improvements were made to the NuGet package/scripts to make this expectation more transparent:

@lachmatt
Copy link
Contributor

I'm closing the issue as underlying problem was addressed, @cabadam feel free to reopen if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants