Bug 462403

Summary: Possible race condition
Product: [Applications] kdeconnect Reporter: Gergely HORVÁTH <horvathg.1988>
Component: commonAssignee: Albert Vaca Cintora <albertvaka>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Gergely HORVÁTH 2022-11-29 18:57:08 UTC
I was looking at the source and I was wondering if these lines introduce some race condition: https://invent.kde.org/network/kdeconnect-kde/-/blob/master/plugins/mprisremote/mprisremoteplayer.cpp#L64-L73

My thought is the following: if newLength differs from m_length, first the SIGNAL is sent out, than later the value of the variable is updated. Isn't it possible, that the SLOT activates before the variable update happens so the function still receives the older version of the variable value?

Disclaimer: Although I have some programming background and experience related to my job, I have no formal training and also I lack experience with multi threaded applications.