Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does asan Intercept vfork() ? #1784

Open
Zhenhang1213 opened this issue Aug 23, 2024 · 0 comments
Open

Why does asan Intercept vfork() ? #1784

Zhenhang1213 opened this issue Aug 23, 2024 · 0 comments

Comments

@Zhenhang1213
Copy link

Zhenhang1213 commented Aug 23, 2024

Why does asan Intercept vfork() ? using options -lpthread -fsanitize=address -fsanitize=undefined, clang 15.0.4

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include <wait.h>

void *TestPopen(void *arg)
{
printf("hello TestPopen.\n");
pid_t pid = vfork();
if (pid < 0) {
printf("error vfork.\n");
} else if (pid == 0) {
printf("I'm child.\n");
pid_t childPid = vfork();
if (childPid < 0) {
printf("error vfork.\n");
} else if (childPid == 0) {
// vfork a grand processes
printf("I'm grand child, and call exit(0).\n");
_exit(0);
} else {
printf("I'm child vfork, and call exit(0).\n");
_exit(0);
}
} else {
// father Processes
printf("I'm parent.\n");
}
while(1) {
sleep(1);
}
return NULL;
}

int main()
{
printf("hello\n");
pthread_t tid;
int ret = pthread_create(&tid, NULL, TestPopen, NULL);
printf("create pthread ret %d.\n", ret);
while(1) {
sleep(1);
}
return 0;
}

The result is not same without asan

@Zhenhang1213 Zhenhang1213 changed the title Why doesn't asan nesting vfork() Why doesn't asan nesting vfork() with clang? Aug 23, 2024
@Zhenhang1213 Zhenhang1213 changed the title Why doesn't asan nesting vfork() with clang? Why does asan Intercept vfork() ? Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant