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

[Crashtracking] Fix the handling of COMPlus_DbgMiniDumpName #5980

Merged
merged 7 commits into from
Sep 6, 2024

Conversation

kevingosse
Copy link
Collaborator

@kevingosse kevingosse commented Sep 3, 2024

Summary of changes

To distinguish the case when createdump is called because of a crash vs a call from dotnet-dump, we store a dummy value in COMPlus_DbgMiniDumpName: #5852

However, this becomes a problem when the process spawns a child process, as it inherits the dummy COMPlus_DbgMiniDumpName and we lose the original value.

To get around that, this PR saves the original value in DD_INTERNAL_CRASHTRACKING_MINIDUMPNAME so the children can retrieve it.

Reason for change

This prevents the crash dump to be generated when launching the app from a bash script when LD_PRELOAD is set globally.

Implementation details

We discovered that bash provides its own version of the getenv/setenv functions, which leads to some unexpected behavior. To get around that, we use dlsym to fetch the original libc functions.

Test coverage

Added a test with a sample app launched from a bash script.

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Sep 3, 2024

Datadog Report

Branch report: kevin/createdump_child
Commit report: 2088be8
Test service: dd-trace-dotnet

✅ 0 Failed, 360530 Passed, 2324 Skipped, 16h 44m 48.23s Total Time

@andrewlock
Copy link
Member

andrewlock commented Sep 3, 2024

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing the following branches/commits:

Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5980) - mean (70ms)  : 66, 75
     .   : milestone, 70,
    master - mean (69ms)  : 67, 71
     .   : milestone, 69,

    section CallTarget+Inlining+NGEN
    This PR (5980) - mean (1,082ms)  : 1052, 1113
     .   : milestone, 1082,
    master - mean (1,077ms)  : 1053, 1101
     .   : milestone, 1077,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5980) - mean (110ms)  : 105, 114
     .   : milestone, 110,
    master - mean (109ms)  : 105, 112
     .   : milestone, 109,

    section CallTarget+Inlining+NGEN
    This PR (5980) - mean (759ms)  : 737, 781
     .   : milestone, 759,
    master - mean (758ms)  : 739, 778
     .   : milestone, 758,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5980) - mean (93ms)  : 89, 97
     .   : milestone, 93,
    master - mean (92ms)  : 90, 95
     .   : milestone, 92,

    section CallTarget+Inlining+NGEN
    This PR (5980) - mean (714ms)  : 694, 735
     .   : milestone, 714,
    master - mean (710ms)  : 697, 724
     .   : milestone, 710,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5980) - mean (191ms)  : 187, 195
     .   : milestone, 191,
    master - mean (190ms)  : 187, 192
     .   : milestone, 190,

    section CallTarget+Inlining+NGEN
    This PR (5980) - mean (1,165ms)  : 1139, 1191
     .   : milestone, 1165,
    master - mean (1,160ms)  : 1137, 1184
     .   : milestone, 1160,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5980) - mean (277ms)  : 270, 283
     .   : milestone, 277,
    master - mean (274ms)  : 270, 279
     .   : milestone, 274,

    section CallTarget+Inlining+NGEN
    This PR (5980) - mean (922ms)  : 900, 945
     .   : milestone, 922,
    master - mean (922ms)  : 902, 942
     .   : milestone, 922,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (5980) - mean (264ms)  : 260, 268
     .   : milestone, 264,
    master - mean (264ms)  : 259, 268
     .   : milestone, 264,

    section CallTarget+Inlining+NGEN
    This PR (5980) - mean (899ms)  : 880, 917
     .   : milestone, 899,
    master - mean (902ms)  : 883, 922
     .   : milestone, 902,

Loading

@andrewlock
Copy link
Member

andrewlock commented Sep 3, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #5980 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.133
  • All benchmarks have the same allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.81μs 43.8ns 291ns 0.0151 0.00753 0 5.42 KB
master StartStopWithChild netcoreapp3.1 10.2μs 53.7ns 263ns 0.0201 0.0101 0 5.62 KB
master StartStopWithChild net472 16.4μs 69.4ns 269ns 1.01 0.291 0.097 6.06 KB
#5980 StartStopWithChild net6.0 7.76μs 43.3ns 290ns 0.0152 0.00759 0 5.42 KB
#5980 StartStopWithChild netcoreapp3.1 10.2μs 58.2ns 407ns 0.0155 0.00518 0 5.62 KB
#5980 StartStopWithChild net472 16.2μs 49.4ns 191ns 1.01 0.289 0.0963 6.07 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 459μs 336ns 1.3μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 623μs 513ns 1.99μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 833μs 533ns 2.07μs 0.411 0 0 3.3 KB
#5980 WriteAndFlushEnrichedTraces net6.0 476μs 495ns 1.92μs 0 0 0 2.7 KB
#5980 WriteAndFlushEnrichedTraces netcoreapp3.1 655μs 370ns 1.33μs 0 0 0 2.7 KB
#5980 WriteAndFlushEnrichedTraces net472 829μs 597ns 2.23μs 0.414 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 206μs 1.2μs 10.8μs 0.201 0 0 18.45 KB
master SendRequest netcoreapp3.1 228μs 1.31μs 10.5μs 0.214 0 0 20.61 KB
master SendRequest net472 0.00371ns 0.00125ns 0.00483ns 0 0 0 0 b
#5980 SendRequest net6.0 202μs 1.18μs 10.8μs 0.2 0 0 18.45 KB
#5980 SendRequest netcoreapp3.1 230μs 1.38μs 13.7μs 0.21 0 0 20.61 KB
#5980 SendRequest net472 0.000341ns 0.000243ns 0.00091ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 585μs 3.29μs 21.6μs 0.598 0 0 41.65 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 686μs 3.75μs 21.2μs 0.326 0 0 41.64 KB
master WriteAndFlushEnrichedTraces net472 887μs 4.29μs 18.2μs 8.13 2.57 0.428 53.31 KB
#5980 WriteAndFlushEnrichedTraces net6.0 580μs 2.98μs 14.6μs 0.581 0 0 41.61 KB
#5980 WriteAndFlushEnrichedTraces netcoreapp3.1 686μs 3.73μs 20.8μs 0.349 0 0 41.64 KB
#5980 WriteAndFlushEnrichedTraces net472 891μs 3.94μs 15.3μs 8.48 2.23 0.446 53.3 KB
Benchmarks.Trace.DbCommandBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #5980

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery‑net6.0 1.133 1,334.86 1,178.60

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.34μs 2.17ns 8.42ns 0.0147 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.73μs 1.41ns 5.09ns 0.0139 0 0 1.02 KB
master ExecuteNonQuery net472 2.04μs 2.09ns 8.11ns 0.156 0 0 987 B
#5980 ExecuteNonQuery net6.0 1.18μs 1.2ns 4.5ns 0.0141 0 0 1.02 KB
#5980 ExecuteNonQuery netcoreapp3.1 1.84μs 2.17ns 8.42ns 0.0134 0 0 1.02 KB
#5980 ExecuteNonQuery net472 2.13μs 2.09ns 8.09ns 0.156 0 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.14μs 1.16ns 4.33ns 0.0136 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.54μs 0.544ns 1.96ns 0.0131 0 0 976 B
master CallElasticsearch net472 2.5μs 1.54ns 5.77ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.24μs 1.16ns 4.48ns 0.013 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.71μs 0.784ns 2.93ns 0.0138 0 0 1.02 KB
master CallElasticsearchAsync net472 2.55μs 1.12ns 4.18ns 0.166 0 0 1.05 KB
#5980 CallElasticsearch net6.0 1.18μs 0.371ns 1.39ns 0.0136 0 0 976 B
#5980 CallElasticsearch netcoreapp3.1 1.61μs 0.611ns 2.28ns 0.0135 0 0 976 B
#5980 CallElasticsearch net472 2.52μs 3.32ns 12.4ns 0.157 0 0 995 B
#5980 CallElasticsearchAsync net6.0 1.21μs 0.789ns 2.95ns 0.0134 0 0 952 B
#5980 CallElasticsearchAsync netcoreapp3.1 1.63μs 0.716ns 2.68ns 0.0139 0 0 1.02 KB
#5980 CallElasticsearchAsync net472 2.54μs 1.49ns 5.75ns 0.166 0 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.3μs 0.772ns 2.99ns 0.0131 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.71μs 0.564ns 2.11ns 0.0128 0 0 952 B
master ExecuteAsync net472 1.72μs 1.62ns 6.27ns 0.145 0 0 915 B
#5980 ExecuteAsync net6.0 1.19μs 1.96ns 7.6ns 0.0131 0 0 952 B
#5980 ExecuteAsync netcoreapp3.1 1.63μs 1.11ns 4.15ns 0.013 0 0 952 B
#5980 ExecuteAsync net472 1.74μs 0.793ns 2.97ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.2μs 1.06ns 3.97ns 0.0315 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.11μs 2.11ns 7.9ns 0.0384 0 0 2.76 KB
master SendAsync net472 7.74μs 3.5ns 12.1ns 0.497 0 0 3.15 KB
#5980 SendAsync net6.0 4.23μs 3ns 11.6ns 0.0298 0 0 2.22 KB
#5980 SendAsync netcoreapp3.1 5.13μs 2.7ns 10.1ns 0.036 0 0 2.76 KB
#5980 SendAsync net472 7.8μs 3.04ns 11.8ns 0.497 0 0 3.15 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.56μs 0.729ns 2.82ns 0.0227 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.18μs 1.06ns 3.97ns 0.0218 0 0 1.64 KB
master EnrichedLog net472 2.7μs 2.47ns 8.91ns 0.249 0 0 1.57 KB
#5980 EnrichedLog net6.0 1.57μs 0.791ns 2.96ns 0.0228 0 0 1.64 KB
#5980 EnrichedLog netcoreapp3.1 2.16μs 1.27ns 4.91ns 0.0215 0 0 1.64 KB
#5980 EnrichedLog net472 2.75μs 2.25ns 8.7ns 0.25 0 0 1.57 KB
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 120μs 270ns 1.04μs 0.057 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 119μs 283ns 1.1μs 0.0597 0 0 4.28 KB
master EnrichedLog net472 147μs 130ns 503ns 0.656 0.219 0 4.46 KB
#5980 EnrichedLog net6.0 113μs 195ns 755ns 0 0 0 4.28 KB
#5980 EnrichedLog netcoreapp3.1 119μs 299ns 1.16μs 0.0591 0 0 4.28 KB
#5980 EnrichedLog net472 149μs 238ns 922ns 0.666 0.222 0 4.46 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.99μs 1.1ns 4.11ns 0.03 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.13μs 2.4ns 9.29ns 0.029 0 0 2.2 KB
master EnrichedLog net472 4.95μs 1.36ns 5.27ns 0.319 0 0 2.02 KB
#5980 EnrichedLog net6.0 2.93μs 1.04ns 3.88ns 0.0309 0 0 2.2 KB
#5980 EnrichedLog netcoreapp3.1 4.02μs 1.76ns 6.81ns 0.0301 0 0 2.2 KB
#5980 EnrichedLog net472 4.98μs 1.12ns 4.02ns 0.321 0 0 2.02 KB
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.45μs 0.807ns 3.13ns 0.0159 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.85μs 5.26ns 20.4ns 0.0157 0 0 1.14 KB
master SendReceive net472 2.22μs 1.59ns 6.16ns 0.183 0.00111 0 1.16 KB
#5980 SendReceive net6.0 1.47μs 1.06ns 4.09ns 0.0158 0 0 1.14 KB
#5980 SendReceive netcoreapp3.1 1.74μs 0.718ns 2.69ns 0.0157 0 0 1.14 KB
#5980 SendReceive net472 2.15μs 2.13ns 7.95ns 0.183 0.00107 0 1.16 KB
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.81μs 0.923ns 3.58ns 0.0225 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 3.82μs 1.68ns 6.49ns 0.021 0 0 1.65 KB
master EnrichedLog net472 4.4μs 1.84ns 7.11ns 0.323 0 0 2.04 KB
#5980 EnrichedLog net6.0 2.77μs 1.92ns 7.43ns 0.0222 0 0 1.6 KB
#5980 EnrichedLog netcoreapp3.1 3.8μs 2.37ns 8.22ns 0.021 0 0 1.65 KB
#5980 EnrichedLog net472 4.39μs 1.26ns 4.89ns 0.323 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 430ns 0.391ns 1.46ns 0.00794 0 0 576 B
master StartFinishSpan netcoreapp3.1 557ns 0.261ns 1.01ns 0.00779 0 0 576 B
master StartFinishSpan net472 621ns 0.2ns 0.749ns 0.0916 0 0 578 B
master StartFinishScope net6.0 532ns 0.322ns 1.25ns 0.00984 0 0 696 B
master StartFinishScope netcoreapp3.1 660ns 1.3ns 5.05ns 0.00948 0 0 696 B
master StartFinishScope net472 850ns 0.909ns 3.52ns 0.104 0 0 658 B
#5980 StartFinishSpan net6.0 399ns 0.21ns 0.813ns 0.00806 0 0 576 B
#5980 StartFinishSpan netcoreapp3.1 613ns 0.67ns 2.59ns 0.00771 0 0 576 B
#5980 StartFinishSpan net472 584ns 0.524ns 2.03ns 0.0916 0 0 578 B
#5980 StartFinishScope net6.0 559ns 0.227ns 0.879ns 0.00985 0 0 696 B
#5980 StartFinishScope netcoreapp3.1 721ns 1.54ns 5.98ns 0.0093 0 0 696 B
#5980 StartFinishScope net472 860ns 0.7ns 2.62ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 602ns 0.275ns 1.07ns 0.00972 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 898ns 0.268ns 1ns 0.00945 0 0 696 B
master RunOnMethodBegin net472 1.06μs 0.522ns 2.02ns 0.104 0 0 658 B
#5980 RunOnMethodBegin net6.0 662ns 0.52ns 2.01ns 0.00987 0 0 696 B
#5980 RunOnMethodBegin netcoreapp3.1 931ns 0.398ns 1.54ns 0.00919 0 0 696 B
#5980 RunOnMethodBegin net472 1.08μs 1.04ns 4.04ns 0.104 0 0 658 B

@kevingosse kevingosse marked this pull request as ready for review September 4, 2024 10:28
@kevingosse kevingosse requested review from a team as code owners September 4, 2024 10:28
Copy link
Collaborator

@gleocadie gleocadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevingosse kevingosse force-pushed the kevin/createdump_child branch 2 times, most recently from 8268acc to 7173e8f Compare September 5, 2024 09:37
Comment on lines +349 to +353
real_setenv(DD_INTERNAL_CRASHTRACKING_MINIDUMPNAME, originalMiniDumpName, 1);
}
setenv(COMPlus_DbgMiniDumpName, datadogCrashMarker, 1);
setenv(DOTNET_DbgMiniDumpName, datadogCrashMarker, 1);

real_setenv(COMPlus_DbgMiniDumpName, datadogCrashMarker, 1);
real_setenv(DOTNET_DbgMiniDumpName, datadogCrashMarker, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a silly question, but is there a reason we have to clobber and restore the original values? Why can't we just store our marker in the DD_INTERNAL_ env instead?

@andrewlock andrewlock merged commit c35416b into master Sep 6, 2024
65 of 69 checks passed
@andrewlock andrewlock deleted the kevin/createdump_child branch September 6, 2024 13:04
@github-actions github-actions bot added this to the vNext-v3 milestone Sep 6, 2024
andrewlock pushed a commit that referenced this pull request Sep 6, 2024
## Summary of changes

To distinguish the case when createdump is called because of a crash vs
a call from `dotnet-dump`, we store a dummy value in
`COMPlus_DbgMiniDumpName`:
#5852

However, this becomes a problem when the process spawns a child process,
as it inherits the dummy `COMPlus_DbgMiniDumpName` and we lose the
original value.

To get around that, this PR saves the original value in
`DD_INTERNAL_CRASHTRACKING_MINIDUMPNAME` so the children can retrieve
it.

## Reason for change

This prevents the crash dump to be generated when launching the app from
a bash script when `LD_PRELOAD` is set globally.

## Implementation details

We discovered that bash provides its own version of the
`getenv`/`setenv` functions, which leads to some unexpected behavior. To
get around that, we use `dlsym` to fetch the original libc functions.

## Test coverage

Added a test with a sample app launched from a bash script.
andrewlock pushed a commit that referenced this pull request Sep 11, 2024
## Summary of changes

To distinguish the case when createdump is called because of a crash vs
a call from `dotnet-dump`, we store a dummy value in
`COMPlus_DbgMiniDumpName`:
#5852

However, this becomes a problem when the process spawns a child process,
as it inherits the dummy `COMPlus_DbgMiniDumpName` and we lose the
original value.

To get around that, this PR saves the original value in
`DD_INTERNAL_CRASHTRACKING_MINIDUMPNAME` so the children can retrieve
it.

## Reason for change

This prevents the crash dump to be generated when launching the app from
a bash script when `LD_PRELOAD` is set globally.

## Implementation details

We discovered that bash provides its own version of the
`getenv`/`setenv` functions, which leads to some unexpected behavior. To
get around that, we use `dlsym` to fetch the original libc functions.

## Test coverage

Added a test with a sample app launched from a bash script.
andrewlock added a commit that referenced this pull request Sep 12, 2024
… v2) (#6001)

## Summary of changes

To distinguish the case when createdump is called because of a crash vs
a call from `dotnet-dump`, we store a dummy value in
`COMPlus_DbgMiniDumpName`:
#5852

However, this becomes a problem when the process spawns a child process,
as it inherits the dummy `COMPlus_DbgMiniDumpName` and we lose the
original value.

To get around that, this PR saves the original value in
`DD_INTERNAL_CRASHTRACKING_MINIDUMPNAME` so the children can retrieve
it.

## Reason for change

This prevents the crash dump to be generated when launching the app from
a bash script when `LD_PRELOAD` is set globally.

## Implementation details

We discovered that bash provides its own version of the
`getenv`/`setenv` functions, which leads to some unexpected behavior. To
get around that, we use `dlsym` to fetch the original libc functions.

## Test coverage

Added a test with a sample app launched from a bash script.

## Other details

Backport of #5980

Co-authored-by: Kevin Gosse <kevin.gosse@datadoghq.com>
@andrewlock andrewlock added area:profiler Issues related to the continous-profiler area:profiler area:native-library Automatic instrumentation native C++ code (Datadog.Trace.ClrProfiler.Native) area:shared-components labels Sep 16, 2024
@andrewlock andrewlock removed the area:profiler Issues related to the continous-profiler label Sep 16, 2024
bouwkast added a commit that referenced this pull request Sep 17, 2024
…5980 -> v2) (#6001)"

This reverts commit 86e60bf.

We are suspecting that this is causing application crashes on .NET 6.0 with the Continuous Profiler enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:crashtracking area:native-library Automatic instrumentation native C++ code (Datadog.Trace.ClrProfiler.Native) area:shared-components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants