Skip to content

Commit 8a96986

Browse files
committed
F-15097: document that the Zephyr thread heap hint is set once
wolfSSL_NewThread and wolfSSL_JoinThread both read the global wolfsslThreadHeapHint. Changing it between the two frees memory to the wrong heap. The hint is meant to be set once at startup, so state that instead of supporting a change.
1 parent 5081f55 commit 8a96986

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎doc/dox_comments/header_files/types.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,12 @@ int wc_strncasecmp(const char *s1, const char *s2, size_t n);
359359
\ingroup Threading
360360
\brief Creates a new thread.
361361
362+
On Zephyr the thread object and its stack are allocated with the
363+
global heap hint wolfsslThreadHeapHint and freed with it in
364+
wolfSSL_JoinThread. Set the hint before the first call to
365+
wolfSSL_NewThread. It must not be changed once it has been used for
366+
an allocation: memory would be freed to the wrong heap.
367+
362368
\return 0 on success
363369
\return negative on error
364370

‎wolfssl/wolfcrypt/types.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,8 @@ WOLFSSL_API word32 CheckRunTimeSettings(void);
21972197
k_thread_stack_t* threadStack;
21982198
} THREAD_TYPE;
21992199
#define WOLFSSL_THREAD
2200+
/* Heap hint for thread allocations. Set it before the first
2201+
* wolfSSL_NewThread call and do not change it afterwards. */
22002202
extern void* wolfsslThreadHeapHint;
22012203
/* Native Zephyr condition variable (k_condvar) built on a k_mutex; no
22022204
* POSIX pthread layer required. Only reached when !SINGLE_THREADED, so

0 commit comments

Comments
 (0)