Skip to content

Commit

Permalink
tests/pthread_flood: increase stack size
Browse files Browse the repository at this point in the history
This fixes stack overflows while printing the stack consumption when
newlib is used.
  • Loading branch information
maribu committed Nov 15, 2022
1 parent 35149bd commit fd83529
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/pthread_flood/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@

#include <stdio.h>

#include "architecture.h"
#include "thread.h"
#include "pthread.h"
#include "mutex.h"

static char dummy_stack[MAXTHREADS][THREAD_STACKSIZE_IDLE];
/* note: stack statistics are printed for every thread in tests */
#define STACKSIZE (THREAD_STACKSIZE_TINY + THREAD_EXTRA_STACKSIZE_PRINTF)

static char WORD_ALIGNED dummy_stack[MAXTHREADS][STACKSIZE];
static pthread_t pthread_ids[MAXTHREADS];
static mutex_t testing_mutex;

Expand All @@ -52,7 +56,7 @@ int main(void)
int pthread_cnt = 0;
for (uint8_t i = 0; i < MAXTHREADS; i++) {
pthread_attr_setstackaddr(&th_attr, &(dummy_stack[i]));
pthread_attr_setstacksize(&th_attr, THREAD_STACKSIZE_IDLE);
pthread_attr_setstacksize(&th_attr, sizeof(dummy_stack[0]));
if (pthread_create(&(pthread_ids[i]), &th_attr, thread_func, NULL)) {
break;
}
Expand Down

0 comments on commit fd83529

Please sign in to comment.