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_field_and_count()
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_field_and_count()
RFC
- Till
PS: the bug seems to still be present in the 3.14 branch head
*** db_access.c.orig 2016-05-10 19:02:06.114617433 -0700
--- db_access.c 2016-05-10 19:04:03.027332775 -0700
***************
*** 32,37 ****
--- 32,38 ----
#include "dbCommon.h"
#include "errMdef.h"
#include "recSup.h"
+ #include "dbLock.h"
#include "alarm.h"
#define db_accessHFORdb_accessC
#include "db_access.h"
***************
*** 182,187 ****
--- 183,190 ----
* in the dbAccess.c dbGet() and getOptions() routines.
*/
+ dbScanLock( paddr->precord );
+
switch(buffer_type) {
case(oldDBR_STRING):
status = dbGetField(paddr, DBR_STRING, pbuffer, &zero, nRequest, pfl);
***************
*** 820,827 ****
}
break;
default:
! return -1;
}
if (status) return -1;
return 0;
}
--- 823,834 ----
}
break;
default:
! status = -1;
! break;
}
+
+ dbScanUnlock( paddr->precord );
+
if (status) return -1;
return 0;
}
- Replies:
- Re: Race condition in db_get_field_and_count() (3.14.12) Till Straumann
- Navigate by Date:
- Prev:
Build edm failed on Centos 7 yeeon
- Next:
Re: Race condition in db_get_field_and_count() (3.14.12) Till Straumann
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
<2016>
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Build edm failed on Centos 7 yeeon
- Next:
Re: Race condition in db_get_field_and_count() (3.14.12) Till Straumann
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
<2016>
2017
2018
2019
2020
2021
2022
2023
2024
|