Non thread safe logger can cause segmentation faults
## Summary
The current implementation of the LoggerPluginManager is not thread safe and therefore logging from multiple threads at the same time might cause double frees and access after free errors.
## Steps and/or TTCN-3 code to reproduce
Create a hello world TITAN project using Eclipse and insert the following code:
Makefile:
```
...
# Flags for the C++ compiler:
CXXFLAGS = -Wall -O0 -g -pthread
# Flags for the linker:
LDFLAGS = -pthread
...
```
PCOType.cc:
```cpp
...
#include <pthread.h>
...
void* thread_main(void* arg) {
for (int i = 0; i < 10000; ++i) {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event("Side thread: Message");
TTCN_Logger::end_event();
}
return NULL;
}
...
void PCOType::user_map(const char *system_port)
{
...
pthread_t thread;
pthread_create(&thread, NULL, thread_main, NULL);
for (int i = 0; i < 10000; ++i) {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event("Main thread: Message");
TTCN_Logger::end_event();
}
}
```
## What is the current bug behavior?
The HTC crashes with a segmentation fault.
## What is the expected correct behavior?
Log output is written without memory errors.
## Relevant logs and/or screenshots
Execution log HTC:
```
TTCN-3 Host Controller (parallel mode), version 7/CAX 105 7730 R2A
./LogThreadingProblem: Segmentation fault occurred
./LogThreadingProblem(+0xd5bd7)[0x56033c942bd7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7fc5352d63c0]
./LogThreadingProblem(+0x36af0a)[0x56033cbd7f0a]
./LogThreadingProblem(+0x624c7)[0x56033c8cf4c7]
./LogThreadingProblem(+0x589c5)[0x56033c8c59c5]
./LogThreadingProblem(+0x2889b)[0x56033c89589b]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x9609)[0x7fc5352ca609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43)[0x7fc534ea3293]
```
## Possible fixes
We have already fixed the problem with a mutex around the begin_event and end_event functions.
I'll provide a fixed version on my fork and add the link as a comment here.
Just opening this issue in case someone else has a better solution.
## Titan version
7.2.0 and 8.0.0
## Platform details (OS type and version)
Ubuntu 20.04
/cc @aknappqwt
issue