Race condition in db_get_field_and_count()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Fix Released
|
High
|
Andrew Johnson | ||
3.14 |
Fix Released
|
High
|
Andrew Johnson | ||
3.15 |
Fix Released
|
High
|
Andrew Johnson | ||
3.16 |
Fix Released
|
High
|
Andrew Johnson |
Bug Description
Dehong reported the following bug:
In order to convert between legacy and more 'modern' representation of
data with at least DBR_STATUS auxiliary information
db_access.c: db_get_
calls dbGetField() twice; a first time to retrieve the auxiliary information
(status, timestamps, ...) and a second time to fetch data.
Since the underlying record is not locked across the two calls to dbGetField()
the record could be processed in between and render the auxiliary data
invalid/obsolete.
Proposed fix:
AFAIK, dbScanLock() supports recursion and therefore the easiest
fix would be acquiring the record lock within db_get_
This bug is still present in the 3.14, 3.15 and 3.16 branch heads (as of the time of this filing). The routine (db_get_
RFC
- Till
So much for all our swearing about atomicity...
The fix seems reasonable. Since the record is locked, should also change dbGetField() to dbGet() and avoid unnecessary calls to dbScanLock().