Bug 1424

Summary: cachedb:testframe is not thread safe
Product: unbound Reporter: JINMEI Tatuya <jtatuya>
Component: serverAssignee: unbound team <unbound-team>
Severity: minor CC: cathya, wouter
Priority: P5    
Version: unspecified   
Hardware: Other   
OS: All   

Description JINMEI Tatuya 2017-08-30 18:25:01 CEST
as of svn trunk revision 4322, the testframe cachedb backend is not thread safe.  both testframe_store() and testframe_lookup() refer to or modify testframe_moddata, which is shared by multiple worker threads, without any mutual exclusion.

perhaps the intent is that this backend is only for testing and debugging purposes and is not expected to be used with multiple threads.  but even if so, it's dangerous as a user could enable cachedb (perhaps just out of curiosity) and see various kinds of disruption due to race conditions.

So I suggest either:
- introduce proper locking or other mutex for the access to the backend, or
- explicitly prohibit or auto-disable the use of testframe if more than multiple thread is used
Comment 1 Wouter Wijngaards 2017-08-31 09:35:36 CEST
Hi Jinmei,

Yes, fixed by adding mutex to testframe.  Thanks for the report!

Best regards, Wouter