When program crashes from one of following signals: SIGILL, SIGABRT, SIGBUS, SIGFPE, SIGSEGV,SIGSTKFLT, SIGPIPE, on Android, debuggerd handler is called to handle it. Inside that handler clone is called with following flags: CLONE_THREAD, CLONE_SIGHAND, CLONE_VM, CLONE_CHILD_SETTID, CLONE_CHILD_CLEARTID. When such program is run under Valgrind, Valgrind will report that such clone isn't supported, as Valgrind supports only NPTL clone, vfork and fork. To check for a clone kind Valgrind checks for VKI_CLONE_VM, VKI_CLONE_FS, CLONE_FILES, CLONE_VFORK flags. This allows for clone with set CLONE_VM, CLONE_FS, CLONE_FILES, and without set CLONE_THREAD, to pass as a clone which creates new thread, which isn't the case. On the other hand there is no problem in allowing program to clone a thread without CLONE_FS flag set. As for the missing CLONE_FILES, problem only occurs when Valgrind is run with --track-fds=yes option. Patch in next comment should fix this.
Created attachment 108666 [details] Clone thread without CLONE_FILES and CLONE_FS flags set This patch adds support for cloning a thread without set CLONE_FS and CLONE_FILES, and changing fds trackinng system to allow for Valgrind to run programs which such clone calls with --track-fds=yes option. It was tested on x86, mips32, and mips64 linux.
Created attachment 108667 [details] fd_clone_test This patch adds tests in none/tests/linux which check Valgrind behevior during thread creation with different combination of CLONE_FS, and CLONE_FILES set flags.
Can somebody take a look at these patches?