Skip to content

Conversation

@ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Nov 11, 2025

What does this PR do?

This PR updates the wrap_with_ffi_result and wrap_with_void_ffi_result macros to catch any panics that happen inside them, returning them as errors.

The error handling is made in such a way (see handle_panic_error for details) that it should be able to report back an error even if we fail to do any allocations.

Important note: Because only the macros have been changed, and ffi APIs that don't use the macros are of course not affected and can still trigger panics. If we like this approach, I'll follow-up with a separate PR to update other APIs to use the new macros.

Motivation

In https://docs.google.com/document/d/1weMu9P03KKhPQ-gh9BMqRrEzpa1BnnY0LaSRGJbfc7A/edit?usp=sharing (Datadog-only link, sorry!) we saw ddog_prof_Exporter_send crashing due to what can be summed up as

ddog_prof_Exporter_send (report a profile) ->
  hyper-util tries to do dns resolution in a separate thread pool ->
    tokio failed to create a new thread ->
      panic and we tear down the app because we can't report a profile

This is not good at all, and this PR solves this inspired by earlier work in #815 and #1083.

Additional Notes

While I don't predict that will happen very often, callers that want to opt-out of the catch unwind behavior can still use the ..._no_catch variants of the macros.

The return type change in ddog_crasht_CrashInfoBuilder_build does change the tag enum entries, which unfortunately is a breaking change.

Ideas on how to work around this? This makes the following enum entries change:

  • DDOG_CRASHT_CRASH_INFO_NEW_RESULT_OK => DDOG_CRASHT_RESULT_HANDLE_CRASH_INFO_OK_HANDLE_CRASH_INFO
  • DDOG_CRASHT_CRASH_INFO_NEW_RESULT_ERR => DDOG_CRASHT_RESULT_HANDLE_CRASH_INFO_ERR_HANDLE_CRASH_INFO

How to test the change?

This change includes test coverage. I've also separately tried to sprinkle a few panic! calls manually and tested that it works as expected.

…h_void_ffi_result`

**What does this PR do?**

This PR updates the `wrap_with_ffi_result` and
`wrap_with_void_ffi_result` macros to catch any panics that happen
inside them, returning them as errors.

The error handling is made in such a way (see `handle_panic_error`
for details) that it should be able to report back an error even if we
fail to do any allocations.

Important note: Because only the macros have been changed, and
ffi APIs that don't use the macros are of course not affected and
can still trigger panics. If we like this approach, I'll follow-up
with a separate PR to update other APIs to use the new macros.

**Motivation:**

In <https://docs.google.com/document/d/1weMu9P03KKhPQ-gh9BMqRrEzpa1BnnY0LaSRGJbfc7A/edit?usp=sharing>
(Datadog-only link, sorry!) we saw `ddog_prof_Exporter_send`
crashing due to what can be summed up as

`ddog_prof_Exporter_send` (report a profile) ->
  hyper-util tries to do dns resolution in a separate thread pool ->
    tokio failed to create a new thread ->
      panic and we tear down the app because we can't report a profile

This is not good at all, and this PR solves this inspired by
earlier work in #815 and #1083.

**Additional Notes:**

While I don't predict that will happen very often, callers that
want to opt-out of the catch unwind behavior can still use the
`..._no_catch` variants of the macros.

The return type change in `ddog_crasht_CrashInfoBuilder_build`
does change the tag enum entries, which unfortunately is a
breaking change.

Ideas on how to work around this? This makes the following
enum entries change:

* `DDOG_CRASHT_CRASH_INFO_NEW_RESULT_OK` =>
  `DDOG_CRASHT_RESULT_HANDLE_CRASH_INFO_OK_HANDLE_CRASH_INFO`
* `DDOG_CRASHT_CRASH_INFO_NEW_RESULT_ERR` =>
  `DDOG_CRASHT_RESULT_HANDLE_CRASH_INFO_ERR_HANDLE_CRASH_INFO`

**How to test the change?**

This change includes test coverage. I've also separately tried to
sprinkle a few `panic!` calls manually and tested that it works as
expected.
Copy link
Contributor

@danielsn danielsn left a comment

Choose a reason for hiding this comment

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

What is the consumer supposed to do if there was a panic caught? We should clearly document that.

Comment on lines 16 to 23
const CANNOT_ALLOCATE: &std::ffi::CStr =
c"libdatadog failed: (panic) Cannot allocate error message";
const CANNOT_ALLOCATE_CHAR_SLICE: CharSlice = unsafe {
crate::Slice::from_raw_parts(
CANNOT_ALLOCATE.as_ptr(),
CANNOT_ALLOCATE.to_bytes_with_nul().len(),
)
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to run this with MIRI to make sure we get lifetimes right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Does miri not run our regular test suite? E.g. I somewhat assumed the new tests in utils.rs would be automatically covered... aren't they? 👀

match error {
None => CharSlice::empty(),
Some(err) => CharSlice::from(err.as_ref()),
// When the error is empty (CANNOT_ALLOCATE_ERROR) we assume we failed to allocate an actual
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to special case ddog_error_drop to avoid dropping the static const CANNOT_ALLOCATE_ERROR

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that's the case? Specifically ddog_error_drop receives the Error, not the CharSlice we produce here, so the ddog_error_drop should see the vec with capacity == 0, not the string produced here. But I may be missing something...? 👀

// This pattern of String vs &str comes from
// https://doc.rust-lang.org/std/panic/struct.PanicHookInfo.html#method.payload
if let Some(s) = error.downcast_ref::<String>() {
anyhow::anyhow!("{} failed: (panic) {}", function_name, s)
Copy link
Contributor

Choose a reason for hiding this comment

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

anyhow itself can allocate

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! That's why there's this second catch_unwind: Either anyhow succeeds and we're able to return this error OR it fails and we fall back to the CANNOT_ALLOCATE_ERROR.

This way we should be able to return the nice error in most cases.

@codecov-commenter
Copy link

codecov-commenter commented Nov 11, 2025

Codecov Report

❌ Patch coverage is 81.25000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.20%. Comparing base (3e1bd42) to head (7e19376).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1334      +/-   ##
==========================================
+ Coverage   70.87%   71.20%   +0.32%     
==========================================
  Files         385      392       +7     
  Lines       61838    62763     +925     
==========================================
+ Hits        43828    44689     +861     
- Misses      18010    18074      +64     
Components Coverage Δ
datadog-crashtracker ∅ <ø> (∅)
datadog-crashtracker-ffi ∅ <ø> (∅)
datadog-alloc ∅ <ø> (∅)
data-pipeline ∅ <ø> (∅)
data-pipeline-ffi ∅ <ø> (∅)
ddcommon ∅ <ø> (∅)
ddcommon-ffi ∅ <ø> (∅)
ddtelemetry ∅ <ø> (∅)
ddtelemetry-ffi ∅ <ø> (∅)
dogstatsd-client ∅ <ø> (∅)
datadog-ipc 82.61% <ø> (ø)
datadog-profiling 0.00% <ø> (ø)
datadog-profiling-ffi ∅ <ø> (∅)
datadog-sidecar 36.98% <ø> (+0.80%) ⬆️
datdog-sidecar-ffi 16.40% <ø> (+4.07%) ⬆️
spawn-worker 55.18% <ø> (ø)
tinybytes ∅ <ø> (∅)
datadog-trace-normalization ∅ <ø> (∅)
datadog-trace-obfuscation 94.17% <ø> (ø)
datadog-trace-protobuf ∅ <ø> (∅)
datadog-trace-utils ∅ <ø> (∅)
datadog-tracer-flare 62.06% <ø> (+1.00%) ⬆️
datadog-log ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pr-commenter
Copy link

pr-commenter bot commented Nov 11, 2025

Benchmarks

Comparison

Benchmark execution time: 2025-11-20 11:32:11

Comparing candidate commit 7e19376 in PR branch ivoanjo/crash-handling-experiments with baseline commit a3f9e86 in branch main.

Found 0 performance improvements and 13 performance regressions! Performance is the same for 42 metrics, 2 unstable metrics.

scenario:credit_card/is_card_number/ 3782-8224-6310-005

  • 🟥 execution_time [+3.168µs; +3.391µs] or [+4.042%; +4.326%]

scenario:credit_card/is_card_number/ 378282246310005

  • 🟥 execution_time [+4.003µs; +4.118µs] or [+5.587%; +5.748%]
  • 🟥 throughput [-759648.780op/s; -737944.516op/s] or [-5.443%; -5.288%]

scenario:credit_card/is_card_number/378282246310005

  • 🟥 execution_time [+4.252µs; +4.377µs] or [+6.203%; +6.386%]
  • 🟥 throughput [-877094.866op/s; -851343.732op/s] or [-6.012%; -5.836%]

scenario:credit_card/is_card_number/37828224631000521389798

  • 🟥 execution_time [+7.175µs; +7.209µs] or [+15.693%; +15.768%]
  • 🟥 throughput [-2980137.854op/s; -2965739.029op/s] or [-13.625%; -13.560%]

scenario:credit_card/is_card_number_no_luhn/ 378282246310005

  • 🟥 execution_time [+4.952µs; +4.989µs] or [+9.270%; +9.339%]
  • 🟥 throughput [-1598753.853op/s; -1587699.163op/s] or [-8.541%; -8.482%]

scenario:credit_card/is_card_number_no_luhn/378282246310005

  • 🟥 execution_time [+5.249µs; +5.297µs] or [+10.455%; +10.552%]
  • 🟥 throughput [-1901015.539op/s; -1885220.088op/s] or [-9.544%; -9.465%]

scenario:credit_card/is_card_number_no_luhn/37828224631000521389798

  • 🟥 execution_time [+7.360µs; +7.387µs] or [+16.093%; +16.153%]
  • 🟥 throughput [-3042592.107op/s; -3029614.424op/s] or [-13.914%; -13.855%]

Candidate

Candidate benchmark details

Group 1

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
sql/obfuscate_sql_string execution_time 88.862µs 89.052µs ± 0.129µs 89.038µs ± 0.042µs 89.084µs 89.170µs 89.327µs 90.481µs 1.62% 7.168 74.066 0.15% 0.009µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
sql/obfuscate_sql_string execution_time [89.034µs; 89.070µs] or [-0.020%; +0.020%] None None None

Group 2

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
normalization/normalize_trace/test_trace execution_time 242.290ns 252.351ns ± 12.733ns 246.841ns ± 3.105ns 254.039ns 285.792ns 288.100ns 289.323ns 17.21% 1.784 1.982 5.03% 0.900ns 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
normalization/normalize_trace/test_trace execution_time [250.586ns; 254.116ns] or [-0.699%; +0.699%] None None None

Group 3

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... execution_time 205.640µs 206.128µs ± 0.298µs 206.090µs ± 0.183µs 206.284µs 206.523µs 206.734µs 208.449µs 1.14% 2.775 17.857 0.14% 0.021µs 1 200
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput 4797334.031op/s 4851369.952op/s ± 6992.986op/s 4852250.292op/s ± 4309.572op/s 4855938.894op/s 4859857.281op/s 4861189.856op/s 4862876.733op/s 0.22% -2.723 17.344 0.14% 494.479op/s 1 200
normalization/normalize_name/normalize_name/bad-name execution_time 18.196µs 18.325µs ± 0.094µs 18.308µs ± 0.039µs 18.348µs 18.492µs 18.753µs 18.779µs 2.57% 2.166 6.724 0.51% 0.007µs 1 200
normalization/normalize_name/normalize_name/bad-name throughput 53250419.121op/s 54572995.567op/s ± 276865.721op/s 54621120.379op/s ± 116895.591op/s 54733788.633op/s 54908387.573op/s 54931508.659op/s 54957875.720op/s 0.62% -2.105 6.384 0.51% 19577.363op/s 1 200
normalization/normalize_name/normalize_name/good execution_time 10.640µs 10.860µs ± 0.065µs 10.862µs ± 0.042µs 10.903µs 10.953µs 11.007µs 11.046µs 1.70% -0.317 0.615 0.60% 0.005µs 1 200
normalization/normalize_name/normalize_name/good throughput 90526692.590op/s 92085470.818op/s ± 556301.164op/s 92066729.953op/s ± 357989.060op/s 92431501.266op/s 92962689.791op/s 93351240.387op/s 93982467.607op/s 2.08% 0.362 0.663 0.60% 39336.433op/s 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... execution_time [206.086µs; 206.169µs] or [-0.020%; +0.020%] None None None
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput [4850400.791op/s; 4852339.113op/s] or [-0.020%; +0.020%] None None None
normalization/normalize_name/normalize_name/bad-name execution_time [18.312µs; 18.338µs] or [-0.071%; +0.071%] None None None
normalization/normalize_name/normalize_name/bad-name throughput [54534624.641op/s; 54611366.493op/s] or [-0.070%; +0.070%] None None None
normalization/normalize_name/normalize_name/good execution_time [10.851µs; 10.869µs] or [-0.084%; +0.084%] None None None
normalization/normalize_name/normalize_name/good throughput [92008372.826op/s; 92162568.809op/s] or [-0.084%; +0.084%] None None None

Group 4

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
benching deserializing traces from msgpack to their internal representation execution_time 62.476ms 63.405ms ± 1.952ms 63.179ms ± 0.123ms 63.297ms 63.541ms 71.182ms 82.123ms 29.98% 8.642 76.640 3.07% 0.138ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
benching deserializing traces from msgpack to their internal representation execution_time [63.134ms; 63.675ms] or [-0.427%; +0.427%] None None None

Group 5

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
ip_address/quantize_peer_ip_address_benchmark execution_time 4.950µs 5.015µs ± 0.040µs 5.020µs ± 0.034µs 5.039µs 5.079µs 5.082µs 5.085µs 1.31% 0.080 -1.070 0.79% 0.003µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
ip_address/quantize_peer_ip_address_benchmark execution_time [5.010µs; 5.021µs] or [-0.109%; +0.109%] None None None

Group 6

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... execution_time 533.940µs 534.693µs ± 0.670µs 534.625µs ± 0.255µs 534.903µs 535.234µs 535.541µs 542.750µs 1.52% 8.732 102.519 0.13% 0.047µs 1 200
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput 1842467.710op/s 1870236.383op/s ± 2320.058op/s 1870471.602op/s ± 892.469op/s 1871253.777op/s 1872274.904op/s 1872651.643op/s 1872871.261op/s 0.13% -8.626 100.831 0.12% 164.053op/s 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time 380.829µs 381.511µs ± 0.357µs 381.504µs ± 0.245µs 381.722µs 382.195µs 382.403µs 382.663µs 0.30% 0.546 -0.042 0.09% 0.025µs 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput 2613267.240op/s 2621160.641op/s ± 2449.800op/s 2621206.737op/s ± 1685.132op/s 2623078.253op/s 2624548.101op/s 2625552.484op/s 2625853.145op/s 0.18% -0.541 -0.050 0.09% 173.227op/s 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time 194.734µs 195.287µs ± 0.203µs 195.274µs ± 0.144µs 195.422µs 195.624µs 195.764µs 195.772µs 0.26% 0.161 -0.223 0.10% 0.014µs 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput 5107971.770op/s 5120679.061op/s ± 5331.774op/s 5120998.757op/s ± 3779.766op/s 5124556.389op/s 5128722.327op/s 5132060.549op/s 5135210.081op/s 0.28% -0.155 -0.224 0.10% 377.013op/s 1 200
normalization/normalize_service/normalize_service/[empty string] execution_time 36.957µs 37.169µs ± 0.073µs 37.166µs ± 0.048µs 37.216µs 37.292µs 37.340µs 37.371µs 0.55% 0.167 -0.063 0.20% 0.005µs 1 200
normalization/normalize_service/normalize_service/[empty string] throughput 26758404.434op/s 26904072.239op/s ± 52833.051op/s 26906324.848op/s ± 34718.606op/s 26938899.913op/s 26990722.724op/s 27004578.196op/s 27058494.645op/s 0.57% -0.155 -0.065 0.20% 3735.861op/s 1 200
normalization/normalize_service/normalize_service/test_ASCII execution_time 44.884µs 45.071µs ± 0.165µs 45.057µs ± 0.124µs 45.182µs 45.295µs 45.328µs 46.419µs 3.02% 2.778 20.142 0.37% 0.012µs 1 200
normalization/normalize_service/normalize_service/test_ASCII throughput 21542876.908op/s 22187434.819op/s ± 80537.771op/s 22194205.655op/s ± 61273.301op/s 22254729.256op/s 22278128.774op/s 22278970.446op/s 22279455.668op/s 0.38% -2.625 18.516 0.36% 5694.880op/s 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... execution_time [534.600µs; 534.786µs] or [-0.017%; +0.017%] None None None
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput [1869914.846op/s; 1870557.921op/s] or [-0.017%; +0.017%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time [381.461µs; 381.560µs] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput [2620821.122op/s; 2621500.159op/s] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time [195.259µs; 195.315µs] or [-0.014%; +0.014%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput [5119940.129op/s; 5121417.994op/s] or [-0.014%; +0.014%] None None None
normalization/normalize_service/normalize_service/[empty string] execution_time [37.159µs; 37.179µs] or [-0.027%; +0.027%] None None None
normalization/normalize_service/normalize_service/[empty string] throughput [26896750.087op/s; 26911394.392op/s] or [-0.027%; +0.027%] None None None
normalization/normalize_service/normalize_service/test_ASCII execution_time [45.048µs; 45.094µs] or [-0.051%; +0.051%] None None None
normalization/normalize_service/normalize_service/test_ASCII throughput [22176273.059op/s; 22198596.580op/s] or [-0.050%; +0.050%] None None None

Group 7

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
credit_card/is_card_number/ execution_time 3.893µs 3.913µs ± 0.006µs 3.912µs ± 0.001µs 3.913µs 3.916µs 3.919µs 3.969µs 1.46% 7.312 67.071 0.15% 0.000µs 1 200
credit_card/is_card_number/ throughput 251953949.206op/s 255589350.691op/s ± 370604.704op/s 255624897.865op/s ± 88615.835op/s 255711982.670op/s 255820320.134op/s 255864003.642op/s 256840204.294op/s 0.48% -7.244 66.340 0.14% 26205.710op/s 1 200
credit_card/is_card_number/ 3782-8224-6310-005 execution_time 80.387µs 81.654µs ± 0.552µs 81.598µs ± 0.430µs 82.087µs 82.527µs 82.770µs 83.175µs 1.93% 0.193 -0.622 0.67% 0.039µs 1 200
credit_card/is_card_number/ 3782-8224-6310-005 throughput 12022805.796op/s 12247375.986op/s ± 82680.986op/s 12255174.267op/s ± 64717.651op/s 12311396.660op/s 12364389.774op/s 12414424.031op/s 12439824.876op/s 1.51% -0.166 -0.632 0.67% 5846.429op/s 1 200
credit_card/is_card_number/ 378282246310005 execution_time 75.348µs 75.715µs ± 0.170µs 75.684µs ± 0.102µs 75.839µs 76.001µs 76.218µs 76.284µs 0.79% 0.635 0.622 0.22% 0.012µs 1 200
credit_card/is_card_number/ 378282246310005 throughput 13108837.752op/s 13207458.378op/s ± 29549.476op/s 13212853.305op/s ± 17767.380op/s 13226857.134op/s 13252387.487op/s 13265624.787op/s 13271772.268op/s 0.45% -0.620 0.593 0.22% 2089.463op/s 1 200
credit_card/is_card_number/37828224631 execution_time 3.895µs 3.912µs ± 0.002µs 3.912µs ± 0.001µs 3.914µs 3.916µs 3.918µs 3.921µs 0.21% -1.339 11.979 0.06% 0.000µs 1 200
credit_card/is_card_number/37828224631 throughput 255057459.249op/s 255598368.687op/s ± 163282.621op/s 255599485.502op/s ± 89623.166op/s 255687573.609op/s 255824038.844op/s 255854167.762op/s 256757945.438op/s 0.45% 1.362 12.144 0.06% 11545.825op/s 1 200
credit_card/is_card_number/378282246310005 execution_time 72.127µs 72.864µs ± 0.207µs 72.893µs ± 0.117µs 72.990µs 73.182µs 73.268µs 73.392µs 0.69% -0.575 1.065 0.28% 0.015µs 1 200
credit_card/is_card_number/378282246310005 throughput 13625430.978op/s 13724345.676op/s ± 39010.747op/s 13718795.024op/s ± 22021.905op/s 13744903.241op/s 13795137.287op/s 13840785.673op/s 13864461.427op/s 1.06% 0.598 1.103 0.28% 2758.476op/s 1 200
credit_card/is_card_number/37828224631000521389798 execution_time 52.705µs 52.913µs ± 0.084µs 52.901µs ± 0.040µs 52.945µs 53.111µs 53.213µs 53.218µs 0.60% 1.399 3.223 0.16% 0.006µs 1 200
credit_card/is_card_number/37828224631000521389798 throughput 18790789.809op/s 18898977.644op/s ± 30067.315op/s 18903135.102op/s ± 14198.769op/s 18915071.529op/s 18936271.773op/s 18951451.730op/s 18973430.973op/s 0.37% -1.383 3.183 0.16% 2126.080op/s 1 200
credit_card/is_card_number/x371413321323331 execution_time 6.429µs 6.439µs ± 0.007µs 6.438µs ± 0.003µs 6.441µs 6.452µs 6.461µs 6.472µs 0.52% 1.589 3.398 0.11% 0.000µs 1 200
credit_card/is_card_number/x371413321323331 throughput 154522950.439op/s 155310824.174op/s ± 163992.645op/s 155333078.179op/s ± 78779.506op/s 155427329.955op/s 155492411.753op/s 155532681.429op/s 155553505.548op/s 0.14% -1.580 3.353 0.11% 11596.031op/s 1 200
credit_card/is_card_number_no_luhn/ execution_time 3.892µs 3.912µs ± 0.003µs 3.912µs ± 0.001µs 3.913µs 3.918µs 3.920µs 3.921µs 0.23% -1.107 13.257 0.07% 0.000µs 1 200
credit_card/is_card_number_no_luhn/ throughput 255037794.367op/s 255604526.514op/s ± 181896.464op/s 255616362.326op/s ± 88623.922op/s 255707690.410op/s 255810453.838op/s 255891606.013op/s 256922101.360op/s 0.51% 1.137 13.470 0.07% 12862.022op/s 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time 64.978µs 65.179µs ± 0.127µs 65.158µs ± 0.075µs 65.237µs 65.428µs 65.582µs 65.748µs 0.91% 1.430 2.785 0.19% 0.009µs 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput 15209514.519op/s 15342343.462op/s ± 29782.154op/s 15347266.791op/s ± 17694.956op/s 15363634.281op/s 15377580.795op/s 15383997.140op/s 15389751.964op/s 0.28% -1.414 2.719 0.19% 2105.916op/s 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time 58.203µs 58.397µs ± 0.127µs 58.365µs ± 0.078µs 58.467µs 58.678µs 58.771µs 58.851µs 0.83% 1.097 0.973 0.22% 0.009µs 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 throughput 16992126.817op/s 17124366.377op/s ± 37197.024op/s 17133536.443op/s ± 22854.126op/s 17152491.462op/s 17167699.831op/s 17177533.642op/s 17181129.965op/s 0.28% -1.086 0.939 0.22% 2630.227op/s 1 200
credit_card/is_card_number_no_luhn/37828224631 execution_time 3.894µs 3.912µs ± 0.002µs 3.912µs ± 0.001µs 3.913µs 3.916µs 3.918µs 3.920µs 0.21% -1.381 14.156 0.06% 0.000µs 1 200
credit_card/is_card_number_no_luhn/37828224631 throughput 255105554.414op/s 255623085.259op/s ± 159756.108op/s 255628681.538op/s ± 83881.292op/s 255713492.047op/s 255798872.120op/s 255857159.537op/s 256804722.313op/s 0.46% 1.407 14.359 0.06% 11296.463op/s 1 200
credit_card/is_card_number_no_luhn/378282246310005 execution_time 55.116µs 55.477µs ± 0.172µs 55.436µs ± 0.104µs 55.591µs 55.813µs 55.941µs 55.998µs 1.01% 0.616 0.137 0.31% 0.012µs 1 200
credit_card/is_card_number_no_luhn/378282246310005 throughput 17857861.682op/s 18025502.744op/s ± 55713.604op/s 18038696.393op/s ± 33856.821op/s 18060637.758op/s 18104890.458op/s 18129855.927op/s 18143540.869op/s 0.58% -0.600 0.114 0.31% 3939.547op/s 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time 53.034µs 53.106µs ± 0.027µs 53.106µs ± 0.017µs 53.122µs 53.154µs 53.172µs 53.182µs 0.14% 0.198 0.309 0.05% 0.002µs 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput 18803270.336op/s 18830275.650op/s ± 9401.045op/s 18830218.975op/s ± 6169.309op/s 18836669.704op/s 18845023.319op/s 18853304.475op/s 18855916.752op/s 0.14% -0.194 0.307 0.05% 664.754op/s 1 200
credit_card/is_card_number_no_luhn/x371413321323331 execution_time 6.427µs 6.437µs ± 0.005µs 6.436µs ± 0.003µs 6.440µs 6.446µs 6.452µs 6.455µs 0.29% 0.898 1.140 0.08% 0.000µs 1 200
credit_card/is_card_number_no_luhn/x371413321323331 throughput 154916073.171op/s 155349235.729op/s ± 120054.369op/s 155371854.389op/s ± 61290.860op/s 155419979.239op/s 155517247.566op/s 155565627.646op/s 155599104.614op/s 0.15% -0.892 1.128 0.08% 8489.126op/s 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
credit_card/is_card_number/ execution_time [3.912µs; 3.913µs] or [-0.020%; +0.020%] None None None
credit_card/is_card_number/ throughput [255537988.444op/s; 255640712.939op/s] or [-0.020%; +0.020%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 execution_time [81.577µs; 81.730µs] or [-0.094%; +0.094%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 throughput [12235917.196op/s; 12258834.775op/s] or [-0.094%; +0.094%] None None None
credit_card/is_card_number/ 378282246310005 execution_time [75.692µs; 75.739µs] or [-0.031%; +0.031%] None None None
credit_card/is_card_number/ 378282246310005 throughput [13203363.104op/s; 13211553.651op/s] or [-0.031%; +0.031%] None None None
credit_card/is_card_number/37828224631 execution_time [3.912µs; 3.913µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/37828224631 throughput [255575739.286op/s; 255620998.088op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/378282246310005 execution_time [72.835µs; 72.892µs] or [-0.039%; +0.039%] None None None
credit_card/is_card_number/378282246310005 throughput [13718939.162op/s; 13729752.191op/s] or [-0.039%; +0.039%] None None None
credit_card/is_card_number/37828224631000521389798 execution_time [52.901µs; 52.925µs] or [-0.022%; +0.022%] None None None
credit_card/is_card_number/37828224631000521389798 throughput [18894810.603op/s; 18903144.685op/s] or [-0.022%; +0.022%] None None None
credit_card/is_card_number/x371413321323331 execution_time [6.438µs; 6.440µs] or [-0.015%; +0.015%] None None None
credit_card/is_card_number/x371413321323331 throughput [155288096.371op/s; 155333551.978op/s] or [-0.015%; +0.015%] None None None
credit_card/is_card_number_no_luhn/ execution_time [3.912µs; 3.913µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/ throughput [255579317.413op/s; 255629735.615op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time [65.162µs; 65.197µs] or [-0.027%; +0.027%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput [15338215.942op/s; 15346470.982op/s] or [-0.027%; +0.027%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time [58.379µs; 58.414µs] or [-0.030%; +0.030%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 throughput [17119211.227op/s; 17129521.527op/s] or [-0.030%; +0.030%] None None None
credit_card/is_card_number_no_luhn/37828224631 execution_time [3.912µs; 3.912µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/37828224631 throughput [255600944.599op/s; 255645225.919op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/378282246310005 execution_time [55.454µs; 55.501µs] or [-0.043%; +0.043%] None None None
credit_card/is_card_number_no_luhn/378282246310005 throughput [18017781.375op/s; 18033224.114op/s] or [-0.043%; +0.043%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time [53.102µs; 53.110µs] or [-0.007%; +0.007%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput [18828972.755op/s; 18831578.544op/s] or [-0.007%; +0.007%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 execution_time [6.436µs; 6.438µs] or [-0.011%; +0.011%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 throughput [155332597.348op/s; 155365874.110op/s] or [-0.011%; +0.011%] None None None

Group 8

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
receiver_entry_point/report/2597 execution_time 6.068ms 6.368ms ± 0.095ms 6.397ms ± 0.020ms 6.417ms 6.435ms 6.468ms 6.581ms 2.87% -1.785 2.389 1.49% 0.007ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
receiver_entry_point/report/2597 execution_time [6.355ms; 6.381ms] or [-0.207%; +0.207%] None None None

Group 9

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
benching string interning on wordpress profile execution_time 161.798µs 162.512µs ± 0.360µs 162.459µs ± 0.140µs 162.616µs 162.935µs 163.885µs 165.507µs 1.88% 4.120 27.992 0.22% 0.025µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
benching string interning on wordpress profile execution_time [162.463µs; 162.562µs] or [-0.031%; +0.031%] None None None

Group 10

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
concentrator/add_spans_to_concentrator execution_time 10.599ms 10.635ms ± 0.017ms 10.634ms ± 0.010ms 10.644ms 10.665ms 10.672ms 10.724ms 0.85% 0.826 2.824 0.16% 0.001ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
concentrator/add_spans_to_concentrator execution_time [10.632ms; 10.637ms] or [-0.022%; +0.022%] None None None

Group 11

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
benching serializing traces from their internal representation to msgpack execution_time 14.838ms 14.895ms ± 0.034ms 14.888ms ± 0.017ms 14.908ms 14.958ms 15.006ms 15.103ms 1.45% 1.911 7.154 0.23% 0.002ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
benching serializing traces from their internal representation to msgpack execution_time [14.890ms; 14.900ms] or [-0.032%; +0.032%] None None None

Group 12

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
write only interface execution_time 1.176µs 3.176µs ± 1.439µs 3.003µs ± 0.021µs 3.022µs 3.281µs 13.835µs 15.226µs 406.99% 7.495 56.856 45.20% 0.102µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
write only interface execution_time [2.976µs; 3.375µs] or [-6.280%; +6.280%] None None None

Group 13

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
redis/obfuscate_redis_string execution_time 33.353µs 33.834µs ± 0.818µs 33.470µs ± 0.065µs 33.594µs 35.481µs 35.576µs 38.100µs 13.83% 2.020 3.588 2.41% 0.058µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
redis/obfuscate_redis_string execution_time [33.720µs; 33.947µs] or [-0.335%; +0.335%] None None None

Group 14

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
tags/replace_trace_tags execution_time 2.353µs 2.388µs ± 0.012µs 2.388µs ± 0.006µs 2.394µs 2.410µs 2.414µs 2.415µs 1.14% -0.243 0.783 0.50% 0.001µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
tags/replace_trace_tags execution_time [2.386µs; 2.389µs] or [-0.070%; +0.070%] None None None

Group 15

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
two way interface execution_time 17.833µs 25.644µs ± 9.637µs 18.119µs ± 0.143µs 34.367µs 43.649µs 44.366µs 69.009µs 280.85% 0.935 0.495 37.48% 0.681µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
two way interface execution_time [24.309µs; 26.980µs] or [-5.208%; +5.208%] None None None

Group 16

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
single_flag_killswitch/rules-based execution_time 189.950ns 192.960ns ± 2.053ns 192.830ns ± 1.399ns 194.014ns 196.781ns 198.657ns 201.412ns 4.45% 0.969 1.166 1.06% 0.145ns 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
single_flag_killswitch/rules-based execution_time [192.676ns; 193.245ns] or [-0.147%; +0.147%] None None None

Group 17

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7e19376 1763637443 ivoanjo/crash-handling-experiments
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
sdk_test_data/rules-based execution_time 144.905µs 147.236µs ± 1.821µs 146.940µs ± 0.612µs 147.571µs 149.230µs 154.814µs 162.886µs 10.85% 4.733 32.321 1.23% 0.129µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
sdk_test_data/rules-based execution_time [146.984µs; 147.488µs] or [-0.171%; +0.171%] None None None

Baseline

Omitted due to size.

Comment on lines +56 to +65
// A Rust Vec of size 0 [has no allocated memory](https://doc.rust-lang.org/std/vec/struct.Vec.html#guarantees):
// "In particular, if you construct a Vec with capacity 0 via Vec::new, vec![],
// Vec::with_capacity(0), or by calling shrink_to_fit on an empty Vec, it will not allocate
// memory." And as per https://doc.rust-lang.org/nomicon/vec/vec-dealloc.html:
// "We must not call alloc::dealloc when self.cap == 0, as in this case we haven't actually
// allocated any memory."
if self.capacity == 0 {
return;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Was this necessary in some case?

This should naturally be handled by Drop for std::vec::Vec, because it's safe to drop an empty std::vec::Vec. After creating a std::vec::Vec of its contents, the FFI Vec will now be "dropped" but drops on pointers do nothing. I can't see why it would be necessary to early-return here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question... At some point in my experiments I was using the mockalloc crate and it complained that we were still trying to drop the vec...

But I'm not confident if that's a real issue with our code or just some artifact of that crate/how I was setting up my test.

As you mentioned the alloc::vec::Vec::from_raw_parts doc kinda states that ptr only needs to be non-null and aligned if capacity is zero (e.g. doesn't need to be allocated using the global allocator) which means it won't touch it.

I'll leave it here to see if anyone has any ideas on why this may or may not be needed; and if nobody else chimes in I'll undo this part of the change.

@danielsn
Copy link
Contributor

If we do catch_unwind, we lose the rust frames for debugging. Anything we can do about that?

@danielsn
Copy link
Contributor

Possibly we should publish a crash report when this panic happens?

@ivoanjo
Copy link
Member Author

ivoanjo commented Nov 12, 2025

Possibly we should publish a crash report when this panic happens?

That would be cool! As a bonus we could actually include the panic message, which right now we don't get.

@dd-octo-sts
Copy link

dd-octo-sts bot commented Nov 14, 2025

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.32 MB 7.32 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 84.53 MB 84.81 MB +.33% (+289.87 KB) 🔍
aarch64-apple-darwin
Artifact Baseline Commit Change
/aarch64-apple-darwin/lib/libdatadog_profiling.a 56.91 MB 57.13 MB +.38% (+225.31 KB) 🔍
/aarch64-apple-darwin/lib/libdatadog_profiling.dylib 8.30 MB 8.28 MB --.17% (-15.14 KB) 💪
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 98.10 MB 98.43 MB +.34% (+344.66 KB) 🔍
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 9.36 MB 9.42 MB +.68% (+66.09 KB) 🔍
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 18.92 MB 19.04 MB +.60% (+117.50 KB) 🔍
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 65.49 KB 65.49 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 132.79 MB 133.61 MB +.61% (+840.00 KB) 🔍
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 709.49 MB 714.51 MB +.70% (+5.01 MB) 🔍
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 6.18 MB 6.21 MB +.41% (+26.50 KB) 🔍
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 65.49 KB 65.49 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 19.25 MB 19.30 MB +.24% (+48.00 KB) 🔍
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 37.83 MB 37.94 MB +.29% (+113.80 KB) 🔍
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 16.06 MB 16.16 MB +.62% (+103.00 KB) 🔍
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 66.50 KB 66.50 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 134.97 MB 135.87 MB +.67% (+928.00 KB) 🔍
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 697.83 MB 702.81 MB +.71% (+4.98 MB) 🔍
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 4.74 MB 4.76 MB +.37% (+18.00 KB) 🔍
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 66.50 KB 66.50 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 20.43 MB 20.51 MB +.38% (+80.00 KB) 🔍
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 35.60 MB 35.73 MB +.34% (+125.25 KB) 🔍
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 72.97 MB 73.25 MB +.37% (+279.41 KB) 🔍
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.71 MB 8.73 MB +.13% (+12.00 KB) 🔍
x86_64-apple-darwin
Artifact Baseline Commit Change
/x86_64-apple-darwin/lib/libdatadog_profiling.a 58.38 MB 58.53 MB +.26% (+157.36 KB) 🔍
/x86_64-apple-darwin/lib/libdatadog_profiling.dylib 9.36 MB 9.32 MB --.49% (-47.63 KB) 💪
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 92.47 MB 92.80 MB +.35% (+333.74 KB) 🔍
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.10 MB 10.12 MB +.11% (+12.17 KB) 🔍

// When the error is empty (CANNOT_ALLOCATE_ERROR) we assume we failed to allocate an actual
// error and return this placeholder message instead.
Some(err) => {
if *err == CANNOT_ALLOCATE_ERROR {
Copy link
Member

Choose a reason for hiding this comment

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

I believe this is going to match any Error with empty message, not necessarily CANNOT_ALLOCATE_ERROR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup -- I've tweaked the comment to clarify this is intentional: f060873 .

I tried to have a different, static non-empty marker but it needed other changes to make the type system happy so that's why I ended up picking this direction.


#[named]
unsafe fn ddog_crasht_crash_info_builder_build_impl(
pub unsafe extern "C" fn ddog_crasht_CrashInfoBuilder_build(
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are catching these, I wonder what the difference is, if any, with extern "C" vs extern "C-unwind". Have you come across any size differences or anything else which might suggest using one or the other in cases when we catch panics?

Copy link
Member Author

Choose a reason for hiding this comment

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

So from my reading of https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html I'm not sure extern "C-unwind" is different from extern "C" here... 🤔

In particular, there's never unwinding from another language to rust (that I know of?), and there's no unwinding from rust into another language -- previously we panic'd directly, and now we're handing the rust panic in rust code, and returning an error.

So there's never, that I can think of, to/from rust boundaries being crossed with unwinding, so this should never apply.

I suspect in practice, since this is a static string, it doesn't make
a difference but let's fix it still.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants