From 102e4447f8b19a29c8c0c0ad95942a62d596ed5a Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Thu, 14 Aug 2025 11:36:21 +0200 Subject: [PATCH 1/2] fix(cfapi): only log process info if it's present Some callbacks do not contain a valid value for the `ProcessInfo` member despite `CF_CONNECT_FLAG_REQUIRE_PROCESS_INFO` being set. Signed-off-by: Jyrki Gadinger --- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 44 ++++++++++++++++---------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 045b367b8f..00aa500d22 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -129,8 +129,8 @@ void cfApiSendTransferInfo(const CF_CONNECTION_KEY &connectionKey, const CF_TRAN void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const CF_CALLBACK_PARAMETERS *callbackParameters) { qCDebug(lcCfApiWrapper) << "Fetch data callback called. File size:" << callbackInfo->FileSize.QuadPart; - qCInfo(lcCfApiWrapper) << "Desktop client proccess id:" << QCoreApplication::applicationPid(); - qCInfo(lcCfApiWrapper) << "Fetch data requested by proccess id:" << callbackInfo->ProcessInfo->ProcessId; + qCInfo(lcCfApiWrapper) << "Desktop client process id:" << QCoreApplication::applicationPid(); + qCInfo(lcCfApiWrapper) << "Fetch data requested by process id:" << callbackInfo->ProcessInfo->ProcessId; qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); const auto sendTransferError = [=] { @@ -356,9 +356,11 @@ void CALLBACK cfApiCancelFetchData(const CF_CALLBACK_INFO *callbackInfo, const C const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); qCInfo(lcCfApiWrapper) << "Cancel fetch data of" << path; - qCInfo(lcCfApiWrapper) << "Desktop client proccess id:" << QCoreApplication::applicationPid(); - qCInfo(lcCfApiWrapper) << "Fetch data requested by proccess id:" << callbackInfo->ProcessInfo->ProcessId; - qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + qCInfo(lcCfApiWrapper) << "Desktop client process id:" << QCoreApplication::applicationPid(); + if (callbackInfo->ProcessInfo) { + qCInfo(lcCfApiWrapper) << "Cancel fetch data requested by process id:" << callbackInfo->ProcessInfo->ProcessId; + qCInfo(lcCfApiWrapper) << "Cancel fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + } auto vfs = reinterpret_cast(callbackInfo->CallbackContext); Q_ASSERT(vfs->metaObject()->className() == QByteArrayLiteral("OCC::VfsCfApi")); @@ -380,9 +382,11 @@ void CALLBACK cfApiNotifyFileOpenCompletion(const CF_CALLBACK_INFO *callbackInfo const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); qCDebug(lcCfApiWrapper) << "Open file completion:" << path << requestId; - qCInfo(lcCfApiWrapper) << "Desktop client proccess id:" << QCoreApplication::applicationPid(); - qCInfo(lcCfApiWrapper) << "Fetch data requested by proccess id:" << callbackInfo->ProcessInfo->ProcessId; - qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + qCInfo(lcCfApiWrapper) << "Desktop client process id:" << QCoreApplication::applicationPid(); + if (callbackInfo->ProcessInfo) { + qCInfo(lcCfApiWrapper) << "Open file completed by process id:" << callbackInfo->ProcessInfo->ProcessId; + qCInfo(lcCfApiWrapper) << "Open file completed by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + } } void CALLBACK cfApiValidateData(const CF_CALLBACK_INFO *callbackInfo, const CF_CALLBACK_PARAMETERS * /*callbackParameters*/) @@ -394,9 +398,11 @@ void CALLBACK cfApiValidateData(const CF_CALLBACK_INFO *callbackInfo, const CF_C const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); qCDebug(lcCfApiWrapper) << "Validate data:" << path << requestId; - qCInfo(lcCfApiWrapper) << "Desktop client proccess id:" << QCoreApplication::applicationPid(); - qCInfo(lcCfApiWrapper) << "Fetch data requested by proccess id:" << callbackInfo->ProcessInfo->ProcessId; - qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + qCInfo(lcCfApiWrapper) << "Desktop client process id:" << QCoreApplication::applicationPid(); + if (callbackInfo->ProcessInfo) { + qCInfo(lcCfApiWrapper) << "Validate data requested by process id:" << callbackInfo->ProcessInfo->ProcessId; + qCInfo(lcCfApiWrapper) << "Validate data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + } } void CALLBACK cfApiCancelFetchPlaceHolders(const CF_CALLBACK_INFO *callbackInfo, const CF_CALLBACK_PARAMETERS * /*callbackParameters*/) @@ -408,9 +414,11 @@ void CALLBACK cfApiCancelFetchPlaceHolders(const CF_CALLBACK_INFO *callbackInfo, const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); qCDebug(lcCfApiWrapper) << "Cancel fetch placeholder:" << path << requestId; - qCInfo(lcCfApiWrapper) << "Desktop client proccess id:" << QCoreApplication::applicationPid(); - qCInfo(lcCfApiWrapper) << "Fetch data requested by proccess id:" << callbackInfo->ProcessInfo->ProcessId; - qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + qCInfo(lcCfApiWrapper) << "Desktop client process id:" << QCoreApplication::applicationPid(); + if (callbackInfo->ProcessInfo) { + qCInfo(lcCfApiWrapper) << "Cancel fetch placeholder requested by process id:" << callbackInfo->ProcessInfo->ProcessId; + qCInfo(lcCfApiWrapper) << "Cancel fetch placeholder requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + } } void CALLBACK cfApiNotifyFileCloseCompletion(const CF_CALLBACK_INFO *callbackInfo, const CF_CALLBACK_PARAMETERS * /*callbackParameters*/) @@ -422,9 +430,11 @@ void CALLBACK cfApiNotifyFileCloseCompletion(const CF_CALLBACK_INFO *callbackInf const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); qCDebug(lcCfApiWrapper) << "Close file completion:" << path << requestId; - qCInfo(lcCfApiWrapper) << "Desktop client proccess id:" << QCoreApplication::applicationPid(); - qCInfo(lcCfApiWrapper) << "Fetch data requested by proccess id:" << callbackInfo->ProcessInfo->ProcessId; - qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + qCInfo(lcCfApiWrapper) << "Desktop client process id:" << QCoreApplication::applicationPid(); + if (callbackInfo->ProcessInfo) { + qCInfo(lcCfApiWrapper) << "Close file completion by process id:" << callbackInfo->ProcessInfo->ProcessId; + qCInfo(lcCfApiWrapper) << "Close file completion by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + } } CF_CALLBACK_REGISTRATION cfApiCallbacks[] = { From 684e29e18c946a7a46ade24d23bd264fcbd9b671 Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Thu, 14 Aug 2025 14:12:29 +0200 Subject: [PATCH 2/2] fix(cfapi): check for valid ProcessInfo in cfApiFetchDataCallback This shouldn't happen, but just in case it does it'll avoid another crash. Signed-off-by: Jyrki Gadinger --- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 00aa500d22..e61525c29e 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -130,8 +130,6 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const { qCDebug(lcCfApiWrapper) << "Fetch data callback called. File size:" << callbackInfo->FileSize.QuadPart; qCInfo(lcCfApiWrapper) << "Desktop client process id:" << QCoreApplication::applicationPid(); - qCInfo(lcCfApiWrapper) << "Fetch data requested by process id:" << callbackInfo->ProcessInfo->ProcessId; - qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); const auto sendTransferError = [=] { cfApiSendTransferInfo(callbackInfo->ConnectionKey, @@ -158,6 +156,15 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); + if (!callbackInfo->ProcessInfo) { + qCCritical(lcCfApiWrapper) << "Callback parameters did not contain required process info required for the implicit hydration check, aborting" << path << requestId; + sendTransferError(); + return; + } + + qCInfo(lcCfApiWrapper) << "Fetch data requested by process id:" << callbackInfo->ProcessInfo->ProcessId; + qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + if (QCoreApplication::applicationPid() == callbackInfo->ProcessInfo->ProcessId) { qCCritical(lcCfApiWrapper) << "implicit hydration triggered by the client itself. Will lead to a deadlock. Cancel" << path << requestId; sendTransferError();