Bug 386427 - Valgrind unsupported clone on Android
Summary: Valgrind unsupported clone on Android
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Android Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-01 13:41 UTC by Tamara Vlahovic
Modified: 2021-08-27 14:39 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Clone thread without CLONE_FILES and CLONE_FS flags set (9.39 KB, patch)
2017-11-01 13:43 UTC, Tamara Vlahovic
Details
fd_clone_test (10.43 KB, patch)
2017-11-01 13:44 UTC, Tamara Vlahovic
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tamara Vlahovic 2017-11-01 13:41:16 UTC
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.
Comment 1 Tamara Vlahovic 2017-11-01 13:43:30 UTC
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.
Comment 2 Tamara Vlahovic 2017-11-01 13:44:40 UTC
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.
Comment 3 Tamara Vlahovic 2017-11-14 10:25:36 UTC
Can somebody take a look at these patches?