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

clone() fails with CLONE_UNTRACED or without SIGCHLD #2781

Closed
zeux opened this issue Dec 22, 2017 · 5 comments
Closed

clone() fails with CLONE_UNTRACED or without SIGCHLD #2781

zeux opened this issue Dec 22, 2017 · 5 comments
Assignees

Comments

@zeux
Copy link

zeux commented Dec 22, 2017

This came out of #121 where leak sanitizer part of address sanitizer doesn't work under WSL. To reproduce this in a standalone sample, I extracted this code from lsan:

#include <assert.h>
#include <sys/mman.h>
#include <unistd.h>
#include <sched.h>
#include <stdio.h>
#include <errno.h>

int TracerThread(void *)
{
	return 0;
}

int main()
{
	const unsigned kStackSize = 2 * 1024 * 1024;
	void* stack = mmap(0, kStackSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
	printf("stack ptr: %p\n", stack);
	pid_t tracer_pid = clone(TracerThread, (char*)stack + kStackSize, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_UNTRACED, 0);
	printf("tracer pid: %d\n", int(tracer_pid));
	printf("errno: %d\n", errno);
}

Compiling & running this under regular Linux makes clone() return a positive PID; running under WSL however returns PID -1:

stack ptr: 0x7f3763820000
tracer pid: -1
errno: 22

This happens in build 17063

@jstarks
Copy link
Member

jstarks commented Dec 24, 2017

I suspect we don’t yet handle CLONE_UNTRACED.

@therealkenc
Copy link
Collaborator

I thought that too, but oddly the test case fails even if you drop CLONE_UNTRACED from the set.

@jstarks
Copy link
Member

jstarks commented Dec 28, 2017

Oh. Looks like we also don't support non-SIGCHLD signaling without CLONE_THREAD. Which is odd because I added support for that weeks ago. But it turns out it was never merged!

So we'll fix that first, and then we can see if we have time for CLONE_UNTRACED.

@jstarks jstarks changed the title clone() with specific arguments fails clone() fails with CLONE_UNTRACED or without SIGCHLD Dec 30, 2017
@jstarks jstarks self-assigned this Dec 30, 2017
@benhillis
Copy link
Member

Fixed in 17093.

@zeux
Copy link
Author

zeux commented Mar 30, 2018

Confirmed - this works in 17127.

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

4 participants