• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 25441446766

06 May 2026 02:26PM UTC coverage: 56.7% (-0.1%) from 56.83%
25441446766

push

github

web-flow
Vs security fix (#2106)

* VS Security fixes

* reformatting and update to trick sims

* cleanup

* more cleanup

* docs

* Test fix

* added stuff

* More stuff

* test fix

* trick sims update

* trick sims update2

* Rename to allowlist

* Remove returns for allow, disable, allow_all functions

* Change various function returns to bool

* Added free for getaddrinfo.

* Revise Variable Server documentation for security updates

Updated documentation to clarify that the variable server is disabled by default for security reasons and must be enabled prior to initialization. Enhanced security warnings regarding the potential risks of enabling the variable server.

* Warning update and moving adding localhost to after connections are allowed

* Clarify variable server disabled by default for security

Update documentation to clarify variable server security changes.

* Update default allowed IPs in Variable-Server.md

Clarified the default allowed IPs for the variable server.

* Add session deletion in VariableServerSessionThread_test

Fixed memory management by deleting session in the destructor.

---------

Co-authored-by: Brendan Fattig <brendan.fattig@nasa.gov>
Co-authored-by: Hong Chen <hchen99@users.noreply.github.com>
Co-authored-by: Sean Harmeyer <117398532+sharmeye@users.noreply.github.com>
Co-authored-by: Sean Harmeyer <sean.g.harmeyer@nasa.gov>

51 of 102 new or added lines in 4 files covered. (50.0%)

24 existing lines in 6 files now uncovered.

12902 of 22755 relevant lines covered (56.7%)

301334.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.27
/trick_source/sim_services/ThreadBase/SysThread.cpp
1

2
#include <iostream>
3
#include <sstream>
4
#include <stdio.h>
5
#if __linux__
6
#include <sys/syscall.h>
7
#include <sys/types.h>
8
#include <sched.h>
9
#endif
10
#include <signal.h>
11
#include <algorithm>
12
#include <time.h>
13

14
#include "trick/SysThread.hh"
15

16
bool Trick::SysThread::shutdown_finished = false;
17

18
// Construct On First Use to avoid the Static Initialization Fiasco
19
pthread_mutex_t& Trick::SysThread::list_mutex() {
3,528✔
20
    static pthread_mutex_t list_mutex = PTHREAD_MUTEX_INITIALIZER;
21
    return list_mutex;
3,528✔
22
} 
23

24
pthread_cond_t& Trick::SysThread::list_empty_cv() {
×
25
    static pthread_cond_t list_empty_cv = PTHREAD_COND_INITIALIZER;
26
    return list_empty_cv;
×
27
} 
28

29
std::vector<Trick::SysThread *>& Trick::SysThread::all_sys_threads() {
1,314✔
30
    static std::vector<SysThread *> all_sys_threads;
1,314✔
31
    return all_sys_threads;
1,314✔
32
}
33

34
Trick::SysThread::SysThread(std::string in_name) : ThreadBase(in_name) {
792✔
35
    pthread_mutex_init(&_restart_pause_mutex, NULL);
792✔
36
    pthread_cond_init(&_thread_has_paused_cv, NULL);
792✔
37
    pthread_cond_init(&_thread_wakeup_cv, NULL);
792✔
38
    _thread_has_paused = true;
792✔
39
    _thread_should_pause = false;
792✔
40

41
    pthread_mutex_lock(&(list_mutex()));
792✔
42
    all_sys_threads().push_back(this);
792✔
43
    pthread_mutex_unlock(&(list_mutex()));
792✔
44
}
792✔
45

46

47
Trick::SysThread::~SysThread() {
785✔
48
    pthread_mutex_lock(&(list_mutex()));
785✔
49
    if (!shutdown_finished) {
785✔
50
        all_sys_threads().erase(std::remove(all_sys_threads().begin(), all_sys_threads().end(), this), all_sys_threads().end());
37✔
51
    }
52
    pthread_mutex_unlock(&(list_mutex()));
785✔
53
}
785✔
54

55
int Trick::SysThread::ensureAllShutdown() {
187✔
56
    pthread_mutex_lock(&(list_mutex()));
187✔
57

58
    // Cancel all threads
59
    for (SysThread * thread : all_sys_threads()) {
941✔
60
        thread->cancel_thread();
754✔
61
    }
62

63
    // Join all threads
64
    for (SysThread * thread : all_sys_threads()) {
941✔
65
        thread->join_thread();
754✔
66
    }
67

68
    // Success!
69
    shutdown_finished = true;
187✔
70
    pthread_mutex_unlock(&(list_mutex()));
187✔
71

72
    return 0;
187✔
73
}
74

75
// To be called from main thread
76
void Trick::SysThread::force_thread_to_pause() {
11✔
77
    pthread_mutex_lock(&_restart_pause_mutex);
11✔
78
    // Tell thread to pause, and wait for it to signal that it has
79
    _thread_should_pause = true;
11✔
80
    while (!_thread_has_paused) {
11✔
UNCOV
81
        pthread_cond_wait(&_thread_has_paused_cv, &_restart_pause_mutex);
×
82
    }
83
    pthread_mutex_unlock(&_restart_pause_mutex);
11✔
84
}
11✔
85

86
// To be called from main thread
87
void Trick::SysThread::unpause_thread() {
11✔
88
    pthread_mutex_lock(&_restart_pause_mutex);
11✔
89
    // Tell thread to wake up
90
    _thread_should_pause = false;
11✔
91
    pthread_cond_signal(&_thread_wakeup_cv);
11✔
92
    pthread_mutex_unlock(&_restart_pause_mutex);
11✔
93
}
11✔
94

95

96
// To be called from this thread
97
void Trick::SysThread::test_pause() {
2,587,644✔
98
    pthread_mutex_lock(&_restart_pause_mutex) ;
2,587,644✔
99
    if (_thread_should_pause) {
2,587,644✔
100
        // Tell main thread that we're pausing
UNCOV
101
        _thread_has_paused = true;
×
UNCOV
102
        pthread_cond_signal(&_thread_has_paused_cv);
×
103
        
104
        // Wait until we're told to wake up
UNCOV
105
        while (_thread_should_pause) {
×
UNCOV
106
            pthread_cond_wait(&_thread_wakeup_cv, &_restart_pause_mutex);
×
107
        }
108
    }
109

110
    _thread_has_paused = false;
2,587,644✔
111
    pthread_mutex_unlock(&_restart_pause_mutex) ;
2,587,644✔
112
}
2,587,644✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc