Bug 1424 - cachedb:testframe is not thread safe
cachedb:testframe is not thread safe
Product: unbound
Classification: Unclassified
Component: server
Other All
: P5 minor
Assigned To: unbound team
Depends on:
  Show dependency treegraph
Reported: 2017-08-30 18:25 CEST by JINMEI Tatuya
Modified: 2017-08-31 09:35 CEST (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
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