Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • T titan.core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 49
    • Issues 49
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Eclipse Projects
  • Eclipse Titan
  • titan.core
  • Issues
  • #569

Closed
Open
Created Aug 09, 2021 by Tobias Erbshäußer (ITK Engineering GmbH)@terbshaeusser

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:

...

#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

Assignee
Assign to
Time tracking

Copyright © Eclipse Foundation, Inc. All Rights Reserved.     Privacy Policy | Terms of Use | Copyright Agent