Fix a possible use-after-free in EDS transaction rollback#8991
Fix a possible use-after-free in EDS transaction rollback#8991MochalovAlexey wants to merge 1 commit intoFirebirdSQL:masterfrom
Conversation
Raise EDS rollback exception before the connection can be released by deleteTransaction(). Cleanup is still performed by catching the error and rethrow the original exception.
|
I would suggest to use |
| detachFromJrdTran(); | ||
| m_connection.deleteTransaction(tdbb, this); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Why not use class Cleanup here and avoid re-throw and explicit cleanup ?
That would be risky here because the cleanup destructor may throw from deleteTransaction(). |
Because it is a cleanup routine, I would make sure that it cannot throw. Throwing from |
|
Strictly speaking Alexey is correct. I'd say all usages of |
They say clang-tidy can track cases when noexcept functions call non-noexcept functions. May be it can handle destructors and lambdas. In this case it could be enough to mark |
EDS::Transaction::rollback()used to callm_connection.deleteTransaction()before reporting rollback errors. This cleanup may release or delete the owningEDS::Connection.If rollback returned an error, the code then called
conn.raise(), which usesgetDataSourceName()and readsm_dbNamefrom the potentially deleted connection. This could lead to a crash while building the error message.The fix raises the rollback error while the connection is still alive and uses a catch/rethrow block to guarantee external transaction cleanup before propagating the original exception.