Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
drowaudio committed May 23, 2024
1 parent 3c5446c commit c08016d
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 41 deletions.
75 changes: 35 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,43 @@
Dynamic library to catch run-time safety violations heavily inspired by [RADSan](https://github.com/realtime-sanitizer/radsan)

## Features
- [ ] Enable in scope
- [ ] Disable in scope
- [ ] Symbolicated stack-trace
- [x] Enable in scope
- [x] Disable in scope
- [x] Symbolicated stack-trace
- [ ] Build-time flags for checks
- [ ] Run-time options for checks
- [ ] Opt-in for own code
- [ ] linux
- [ ] macOS

## Functions
| First Header | Second Header |
|--------------|---------------|
| - l1 | - [x] |
| - l2 | - [ ] |
- [x] Opt-in for own code
- [x] linux
- [x] macOS (malloc unsupported)

## Functions (test = ✔)
- Time
- [x] sleep
- [x] nanosleep
- [x] usleep
- [x] sleep
- [x] nanosleep
- [x] usleep
- Memory
- [x] malloc
- [x] calloc
- [x] realloc
- [x] free
- [ ] reallocf (macOS)
- [x] valloc
- [x] posix_memalign
- [x] mmap
- [x] munmap
- [x] malloc
- [x] calloc
- [x] realloc
- [x] free
- [x] reallocf
- [x] valloc
- [x] posix_memalign
- [x] mmap
- [x] munmap
- Threads
- [ ] pthread_create
- [ ] pthread_mutex_lock
- [ ] pthread_mutex_unlock
- [ ] pthread_join
- [ ] pthread_cond_signal
- [ ] pthread_cond_broadcast
- [ ] pthread_cond_wait
- [ ] pthread_cond_timedwait
- [ ] pthread_rwlock_rdlock
- [ ] pthread_rwlock_unlock
- [ ] pthread_rwlock_wrlock
- [ ] pthread_spin_lock
- [x] pthread_create
- [x] pthread_mutex_lock
- [x] pthread_mutex_unlock
- [x] pthread_join
- [x] pthread_cond_signal
- [x] pthread_cond_broadcast
- [x] pthread_cond_wait
- [x] pthread_cond_timedwait
- [x] pthread_rwlock_rdlock
- [x] pthread_rwlock_unlock
- [x] pthread_rwlock_wrlock
- [x] pthread_spin_lock (linux)
- Files
- [ ] open
- [ ] openat
Expand All @@ -56,7 +51,7 @@ Dynamic library to catch run-time safety violations heavily inspired by [RADSan]
- [ ] creat
- [ ] puts
- [ ] fputs
- [x] stat
- [x] stat
- [ ] stat64
- [ ] fstat
- [ ] fstat64
Expand All @@ -70,15 +65,15 @@ Dynamic library to catch run-time safety violations heavily inspired by [RADSan]
- [ ] recvfrom
- [ ] shutdown
- System calls
- [x] syscall
- [x] syscall

## CI/Tests
- [ ] Failures
- Failures
- [x] Throwing exceptions
- [x] Large std::function
- [x] Atomic 4*ptr size
- [ ] Dynamic loading of a library
- [ ] Passes
- Passes
- [x] Atomic double
- [x] Small std::function
- [x] Running on CI Linux
Expand Down
11 changes: 10 additions & 1 deletion src/lib_rt_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

static bool has_initialised = false;

inline void log_function_if_realtime_context (const char* function_name)
void log_function_if_realtime_context (const char* function_name)
{
if (! has_initialised)
return;
Expand All @@ -26,6 +26,7 @@ inline void log_function_if_realtime_context (const char* function_name)
std::exit (1);
}


//==============================================================================
// memory
//==============================================================================
Expand Down Expand Up @@ -56,6 +57,14 @@ INTERCEPTOR(void*, realloc, void *ptr, size_t new_size)
return REAL(realloc)(ptr, new_size);
}

INTERCEPTOR(void *, reallocf, void *ptr, size_t size)
{
log_function_if_realtime_context (__func__);

INTERCEPT_FUNCTION(void*, reallocf, void*, size_t);
return REAL(reallocf)(ptr, size);
}

INTERCEPTOR(void*, valloc, size_t size)
{
log_function_if_realtime_context (__func__);
Expand Down
6 changes: 6 additions & 0 deletions src/lib_rt_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ struct non_realtime_context
}
};


//==============================================================================
//==============================================================================
void log_function_if_realtime_context (const char* function_name);


//==============================================================================
inline std::string demangle (std::string name)
{
Expand Down
16 changes: 16 additions & 0 deletions tests/fail_custom_function.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <lib_rt_check.h>

void my_func()
{
log_function_if_realtime_context (__func__);
}

int main()
{
my_func();

realtime_context rc;
my_func();

return 0;
}
11 changes: 11 additions & 0 deletions tests/fail_reallocf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <lib_rt_check.h>

int main()
{
auto res = malloc (1024);

realtime_context rc;
res = reallocf (res, 1024 * 4);

return 0;
}

0 comments on commit c08016d

Please sign in to comment.