Skip to content

Commit

Permalink
add test for issue #944
Browse files Browse the repository at this point in the history
  • Loading branch information
daanx committed Oct 21, 2024
1 parent 638ea53 commit 50d3525
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion test/main-override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ static void tsan_numa_test(); // issue #414
static void strdup_test(); // issue #445
static void heap_thread_free_huge();
static void test_std_string(); // issue #697
static void test_thread_local(); // issue #944

static void test_stl_allocators();


int main() {
// mi_stats_reset(); // ignore earlier allocations

test_std_string();
//test_std_string();
test_thread_local();
// heap_thread_free_huge();
/*
heap_thread_free_large();
Expand Down Expand Up @@ -312,3 +314,31 @@ static void tsan_numa_test() {
dummy_worker();
t1.join();
}


class MTest
{
char *data;
public:
MTest() { data = (char*)malloc(1024); }
~MTest() { free(data); };
};

thread_local MTest tlVariable;

void threadFun( int i )
{
printf( "Thread %d\n", i );
std::this_thread::sleep_for( std::chrono::milliseconds(100) );
}

void test_thread_local()
{
for( int i=1; i < 100; ++i )
{
std::thread t( threadFun, i );
t.join();
mi_stats_print(NULL);
}
return;
}

0 comments on commit 50d3525

Please sign in to comment.