You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[#28913] YSQL: Fix dangling std::string::c_str() setting up YbcFlushDebugContext
Summary:
cbbb323 adds a few places where we do something like the following:
```
debug_context.strarg2 = row_id.ybctid().ToDebugHexString().c_str();
```
where `ToDebugHexString()` returns a new `std::string`. The backing `std::string` is destroyed
at the end of the assignment, so `debug_context.strarg2` now contains a dangling pointer. This
is caught in newer clang versions (clang21) with the following error:
```
../../src/yb/yql/pggate/pg_operation_buffer.cc:382:35: error: object backing the pointer 'debug_context.strarg2' will be destroyed at the end of the full-expression [-Werror,-Wdangling-assignment-gsl]
382 | debug_context.strarg2 = row_id.ybctid().ToDebugHexString().c_str();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Fix this by storing the temporary std::string in a separate variable.
Jira: DB-18636
Test Plan: Jenkins. Also compiled locally with clang21 where this fails to compile.
Reviewers: kramanathan, jason
Reviewed By: kramanathan, jason
Subscribers: yql, ybase
Tags: #jenkins-ready
Differential Revision: https://phorge.dev.yugabyte.com/D47365
0 commit comments