Skip to content

Commit a45173c

Browse files
kevingosseveerbia
authored andcommitted
[Crashtracking] Display a nicer error message when the glibc version is too old (#6402)
## Summary of changes Change the error message when loading the profiler fails because of the glibc version. Before: ``` Datadog - Some errors occurred while analyzing the crash: - Unexpected exception: System.DllNotFoundException: Unable to load shared library '/opt/datadog-packages/datadog-apm-library-dotnet/3.6.1/linux-arm64/Datadog.Prof iler.Native.so' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: /lib/aarch64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /opt/datadog-packages/datadog-apm-library-dotnet/3.6.1/linux-arm64/Datadog.Profi ler.Native.so) at System.Runtime.InteropServices.NativeLibrary.LoadLibErrorTracker.Throw(String) + 0x50 at System.Runtime.InteropServices.NativeLibrary.LoadFromPath(String, Boolean) + 0x4c at Datadog.Trace.Tools.dd_dotnet.CreatedumpCommand.GenerateCrashReport(Int32, Nullable`1, Nullable`1) + 0x110 at Datadog.Trace.Tools.dd_dotnet.CreatedumpCommand.Execute(InvocationContext context) + 0x94 ``` After: ``` Datadog - Some errors occurred while analyzing the crash: - The GLIBC version is too old ``` ## Reason for change The error is "expected" in some environment, so it's better to make the message less scary.
1 parent ee3ad4b commit a45173c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tracer/src/Datadog.Trace.Tools.dd_dotnet/CreatedumpCommand.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,17 @@ private unsafe void GenerateCrashReport(int pid, int? signal, int? crashThread)
426426
var extension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "dll" : "so";
427427
var profilerLibrary = $"Datadog.Profiler.Native.{extension}";
428428

429-
var lib = NativeLibrary.Load(Path.Combine(AppContext.BaseDirectory, profilerLibrary));
429+
IntPtr lib;
430+
431+
try
432+
{
433+
lib = NativeLibrary.Load(Path.Combine(AppContext.BaseDirectory, profilerLibrary));
434+
}
435+
catch (DllNotFoundException ex) when (ex.Message.Contains("GLIBC"))
436+
{
437+
Errors.Add($"The GLIBC version is too old");
438+
return;
439+
}
430440

431441
var export = NativeLibrary.GetExport(lib, "CreateCrashReport");
432442

0 commit comments

Comments
 (0)