Fix raise_error() and grab_gvl_and_raise() to use rb_vsprintf() so PRIsVALUE works#5857
Conversation
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 133e02e | Docs | Datadog PR Page | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfcfb720c1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
6f6e08b to
2ec7ba2
Compare
BenchmarksBenchmark execution time: 2026-06-03 19:48:58 Comparing candidate commit 133e02e in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 45 metrics, 1 unstable metrics.
|
…IsVALUE works * So `raise_error(rb_eRuntimeError, "foo %"PRIsVALUE" bar", some_ruby_object)` calls #to_s and doesn't print an integer. (or `"%+"PRIsVALUE` which calls #inspect and not print "+123") * Pass the va_list through rb_thread_call_with_gvl and call rb_vsprintf() inside the callback where the GVL is held (rb_vsprintf allocates Ruby objects). This is safe because rb_thread_call_with_gvl is synchronous so the parent stack frame (where the va_list lives) is still alive. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Now that rb_vsprintf() produces Ruby strings directly, there is no fixed-size C buffer limiting the message length. The artificial 255-char cap is no longer needed. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Test raise_error() via _native_raise_error_value_arg and also through the otel_context_enabled production code path in ThreadContext. Co-Authored-By: Claude Opus 4.6 <[email protected]>
074e7dc to
133e02e
Compare
raise_error(rb_eRuntimeError, "foo %"PRIsVALUE" bar", some_ruby_object)calls #to_s and doesn't print an integer.(or
"%+"PRIsVALUEwhich calls #inspect and not print "+123")inside the callback where the GVL is held (rb_vsprintf allocates Ruby
objects). This is safe because rb_thread_call_with_gvl is synchronous so
the parent stack frame (where the va_list lives) is still alive.
What does this PR do?
^
Motivation:
Correctness and useful error messages.
Change log entry
Yes. Fix some exception messages which were not formatted correctly.
Additional Notes:
How to test the change?