Bug #74849 default_password_lifetime is volatile, doesn't need to be - protected by mutex
Submitted: 14 Nov 2014 3:07 Modified: 21 Nov 2014 15:10
Reporter: Stewart Smith Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.7.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: PowerPC

[14 Nov 2014 3:07] Stewart Smith
Description:
default_password_lifetime is a global variable in mysqld.cc, and indeed a server global variable.

The idea is that when this value is updated, new passwords will have a lifetime of X days.

Since system variables are protected by LOCK_global_system_variables, we have all the appropriate protections for updating default_password_lifetime. The addition of volatile just makes the compiler unable to do some optimization for no good reason.

In reality, this probably isn't much of an issue and the assembler produced is likely correct, but volatile should throw up a red flag everywhere it's used, and if LOCK_global_system_variables suddenly went away, then this code would very subtly become incorrect, with people likely thinking that 'volatile' protects it in ways that it doesn't.

How to repeat:
code analysis.

Suggested fix:
apply my patch! (attached)
[14 Nov 2014 3:08] Stewart Smith
remove volatile from default_password_lifetime

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: volatile-default_password_lifetime.patch (text/x-patch), 1.12 KiB.

[14 Nov 2014 5:27] MySQL Verification Team
Hello Stewart,

Thank you for the report and contribution.

Thanks,
Umesh
[21 Nov 2014 15:10] Paul DuBois
Noted in 5.7.6 changelog.

default_password_lifetime was marked volatile, unnecessarily because
it is protected with a mutex. Thanks to Stewart Smith for the patch.