Skip to content

Commit

Permalink
debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jun 12, 2023
1 parent 6342344 commit f4024a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions dlmalloc/src/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4719,6 +4719,7 @@ void dlfree(void* mem) {

if (mem != 0) {
mchunkptr p = mem2chunk(mem);
memset(mem, 0xaa, chunksize(p) - overhead_for(p));
#if FOOTERS
mstate fm = get_mstate_for(p);
if (!ok_magic(fm)) {
Expand Down
9 changes: 9 additions & 0 deletions libc-top-half/musl/src/thread/pthread_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,14 @@ static int start_c11(void *p)
void wasi_thread_start(int tid, void *p);
hidden void *__dummy_reference = wasi_thread_start;

void *gcanary;

hidden void __wasi_thread_start_C(int tid, void *p)
{
char canary[100];
canary[0] = 123;
canary[99] = 99;
gcanary = canary; // just to avoid "canary" being optimized out
struct start_args *args = p;
pthread_t self = __pthread_self();
// Set the thread ID (TID) on the pthread structure. The TID is stored
Expand All @@ -316,6 +322,9 @@ hidden void __wasi_thread_start_C(int tid, void *p)
atomic_store((atomic_int *) &(self->tid), tid);
// Execute the user's start function.
__pthread_exit(args->start_func(args->start_arg));
if (canary[0] != 123 || canary[99] != 99) {
a_crash();
}
}
#endif

Expand Down

0 comments on commit f4024a1

Please sign in to comment.