`BlockManager::m_block_tree_db` is protected by cs_main, so take the `cs_main` lock while accessing it.
The use of the lambda in `Assert` and the fact that `cs_main` is a global lock rather than scoped within a class means that clang's thread safety checks don't catch this.
After D14620, the following warning appears when building with clang:
```
[364/540] Building CXX object src/CMakeFiles/server.dir/init.cpp.o
/home/pierre/dev/bitcoin-abc/src/init.cpp:2538:45: warning: passing variable 'm_block_tree_db' by reference requires holding mutex 'cs_main' [-Wthread-safety-reference]
*Assert(chainman.m_blockman.m_block_tree_db))}) {
```
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/24672 | core#24672]]