linux-sysprog · beginner · ~15 min
Recognise the shared-loop-variable thread-arg bug.
Implement int arg_passing_safe(const char *how) returning 1 for "heap" or "unique-stack-slot" and 0 for "shared-loop-variable" (the classic bug where every thread sees the final loop value).
#include <string.h>
int arg_passing_safe(const char *how) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.