Bug 369029 - WARNING: unhandled amd64-linux syscall: 315 (sched_getattr)
Summary: WARNING: unhandled amd64-linux syscall: 315 (sched_getattr)
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.11.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Mark Wielaard
URL:
Keywords:
: 368919 368920 369028 405394 422417 423095 425422 425967 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-09-19 06:46 UTC by Marcin Juszkiewicz
Modified: 2021-10-04 09:03 UTC (History)
9 users (show)

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


Attachments
Patch to support sched_getattr and sched_setattr. (4.97 KB, patch)
2020-04-14 23:09 UTC, zephyrus00jp
Details
A test program to test the operation of sched_getattr() and sched_setattr(). (5.49 KB, text/x-csrc)
2020-04-14 23:11 UTC, zephyrus00jp
Details
Log of running the test program under the patched valgrind. (51.48 KB, text/x-log)
2020-04-14 23:14 UTC, zephyrus00jp
Details
manual page of sched_getattr and sched_setattr from Debian GNU/Linux (11.37 KB, text/plain)
2020-04-14 23:30 UTC, zephyrus00jp
Details
Cleaned up patch from bug #405394 (10.93 KB, text/plain)
2020-07-26 22:49 UTC, Mark Wielaard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Juszkiewicz 2016-09-19 06:46:33 UTC
<<<test_start>>>
tag=sched_getattr02_valgrind_memory_leak_check stime=1474195095
cmdline=" valgrind -q --leak-check=full --trace-children=yes sched_getattr02"
contacts=""
analysis=exit
<<<test_output>>>
--24040-- WARNING: unhandled amd64-linux syscall: 315
--24040-- You may be able to write your own handler.
--24040-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--24040-- Nevertheless we consider this a bug.  Please report
--24040-- it at http://valgrind.org/support/bug_reports.html.
--24040-- WARNING: unhandled amd64-linux syscall: 315
--24040-- You may be able to write your own handler.
--24040-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--24040-- Nevertheless we consider this a bug.  Please report
--24040-- it at http://valgrind.org/support/bug_reports.html.
--24040-- WARNING: unhandled amd64-linux syscall: 315
--24040-- You may be able to write your own handler.
--24040-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--24040-- Nevertheless we consider this a bug.  Please report
--24040-- it at http://valgrind.org/support/bug_reports.html.
--24040-- WARNING: unhandled amd64-linux syscall: 315
--24040-- You may be able to write your own handler.
--24040-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--24040-- Nevertheless we consider this a bug.  Please report
--24040-- it at http://valgrind.org/support/bug_reports.html.
sched_getattr02    1  TFAIL  :  sched_getattr02.c:83: sched_getattr() failed unexpectedly : expected: 3 - ESRCH: TEST_ERRNO=ENOSYS(38): Function not implemented
sched_getattr02    2  TFAIL  :  sched_getattr02.c:83: sched_getattr() failed unexpectedly : expected: 22 - EINVAL: TEST_ERRNO=ENOSYS(38): Function not implemented
sched_getattr02    3  TFAIL  :  sched_getattr02.c:83: sched_getattr() failed unexpectedly : expected: 22 - EINVAL: TEST_ERRNO=ENOSYS(38): Function not implemented
sched_getattr02    4  TFAIL  :  sched_getattr02.c:83: sched_getattr() failed unexpectedly : expected: 22 - EINVAL: TEST_ERRNO=ENOSYS(38): Function not implemented
<<<execution_status>>>
initiation_status="ok"
duration=1 termination_type=exited termination_id=1 corefile=no
cutime=68 cstime=2
<<<test_end>>>


Reproducible: Always
Comment 1 Marcin Juszkiewicz 2018-04-30 08:06:56 UTC
Can we close it? IIRC it was merged into valgrind.
Comment 2 zephyrus00jp 2020-04-14 23:06:09 UTC
I have created a crude patch to support sched_getattr and sched_setattr under linux.
I am using Debian GNU/Linux x86_64.

If those in the know can take a look and tidy it up and merge it into the source repository, that would be great.

I am going to upload the patch, a simple test program I created, test log, and 
manual of sched_getattr/sched_setattr for reference.
Comment 3 zephyrus00jp 2020-04-14 23:09:39 UTC
Created attachment 127553 [details]
Patch to support sched_getattr and sched_setattr.

This is the patch for linux (x86_64) created and test under Debian GNU/Linux.
Comment 4 zephyrus00jp 2020-04-14 23:11:20 UTC
Created attachment 127554 [details]
A test program to test the operation of sched_getattr() and sched_setattr().

A simple program that I used to test the support of sched_getattr and sched_setattr by patched valgrind.
Comment 5 zephyrus00jp 2020-04-14 23:14:40 UTC
Created attachment 127555 [details]
Log of running the test program under the patched valgrind.

Log of the program.

In the case of passing the structure mentioned in the manual page, and exact size, the initialization status of memory buffer returned is as expected.

However, if I pass a large buffer (with 1024 octet size), the underlying system call seems to use block copy (16 octets at a time) and I seem to have a memory buffer returned with a few extra octets initialized. Not fatal, and probably a feature. Just interesting.
Comment 6 zephyrus00jp 2020-04-14 23:24:17 UTC
I needed to implement the support for these two system calls because somehow
I found that running thunderbird under valgrind for mozilla test suite called mochitest forced valgrind to create so many tasks (> 1500) and it blew up.
(--max-threads=1500 did not help.)

I filed a bug at mozilla bugzilla.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1629433
Running thunderbird binary under valgrind while trying to run mochitest requires way TOO MANY threads (> 1500) !?


Now that the supporting these system calls via this patch does not seem to change the blowup behavior.

Now I have a feeling that there are so many tasks created related to
futex_wait_cancellable (related to syscall 202), I feel there is a bug in the handling futex calls under x86_64 linux, but then I am not sure why we don't hear from Firefox people about the similar problem...

Anyway merging of the tidied up patch to the source repository of valgrind will be appreciated.

If also, someone can take a look at the log posted at mozilla bugzilla

See https://bugzilla.mozilla.org/show_bug.cgi?id=1629433

and shed some light on the issue, I would appreciate it very much.

TIA
Comment 7 zephyrus00jp 2020-04-14 23:30:55 UTC
Created attachment 127556 [details]
manual page of sched_getattr and sched_setattr from Debian GNU/Linux

Here is the copy of man page of the sched_getattr and sched_setattr calls.
Comment 8 Daniel Wagner 2020-04-15 06:57:59 UTC
*** Bug 405394 has been marked as a duplicate of this bug. ***
Comment 9 Mark Wielaard 2020-06-03 13:32:36 UTC
*** Bug 422417 has been marked as a duplicate of this bug. ***
Comment 10 Mark Wielaard 2020-06-17 18:38:58 UTC
*** Bug 423095 has been marked as a duplicate of this bug. ***
Comment 11 zephyrus00jp 2020-06-18 00:13:07 UTC
I think I need to merge the patch from 405394 into the patch here and then the patch would be complete. Let me remind myself to do this next weekend.
Comment 12 Mark Wielaard 2020-07-26 22:49:41 UTC
Created attachment 130422 [details]
Cleaned up patch from bug #405394

(In reply to zephyrus00jp from comment #11)
> I think I need to merge the patch from 405394 into the patch here and then
> the patch would be complete. Let me remind myself to do this next weekend.

I took your patch and cleaned it up a little. Differences are:
- hooked up all linux arches
- Removed POST handler for sched_setattr (as far as I can see, the kernel only reads from the struct sched_attr, but doesn't write anything back)
- Added a ML_(safe_to_deref) call before reading attr->size (so we don't crash if the user passes in NULL or a bogus address)
- Use the actual attr->size as the memory that must/will be initialized (since the actual struct size could differ in the future).
Comment 13 zephyrus00jp 2020-07-27 00:53:29 UTC
(In reply to Mark Wielaard from comment #12)
> Created attachment 130422 [details]
> Cleaned up patch from bug #405394
> 
> (In reply to zephyrus00jp from comment #11)
> > I think I need to merge the patch from 405394 into the patch here and then
> > the patch would be complete. Let me remind myself to do this next weekend.
> 
> I took your patch and cleaned it up a little. Differences are:
> - hooked up all linux arches
> - Removed POST handler for sched_setattr (as far as I can see, the kernel
> only reads from the struct sched_attr, but doesn't write anything back)
> - Added a ML_(safe_to_deref) call before reading attr->size (so we don't
> crash if the user passes in NULL or a bogus address)
> - Use the actual attr->size as the memory that must/will be initialized
> (since the actual struct size could differ in the future).

Thank you for the cleanup.

I wonder what the merge plan/policy is.
Comment 14 Mark Wielaard 2020-07-28 11:53:01 UTC
(In reply to zephyrus00jp from comment #13)
> Thank you for the cleanup.
> 
> I wonder what the merge plan/policy is.

Currently testing the patch for the Fedora rawhide valgrind package. Looking good. If nobody objects I'll merge it end of the week.
Comment 15 Mark Wielaard 2020-08-01 13:44:47 UTC
commit 6323fd5bfd94c3f80e2ff44f16488e0172bd9a96
Author: Mark Wielaard <mark@klomp.org>
Date:   Mon Jul 27 16:36:17 2020 +0200

    Handle linux syscalls sched_getattr and sched_setattr
    
    The only "special" thing about these syscalls is that the given
    struct sched_attr determines its own size for future expansion.
    
    Original fix by "ISHIKAWA,chiaki" <ishikawa@yk.rim.or.jp>
    
    https://bugs.kde.org/show_bug.cgi?id=369029
Comment 16 Tom Hughes 2020-08-16 13:34:55 UTC
*** Bug 425422 has been marked as a duplicate of this bug. ***
Comment 17 Tom Hughes 2020-08-30 07:55:00 UTC
*** Bug 425967 has been marked as a duplicate of this bug. ***
Comment 18 Mark Wielaard 2020-12-20 11:49:47 UTC
*** Bug 430597 has been marked as a duplicate of this bug. ***
Comment 19 Mark Wielaard 2020-12-20 20:24:29 UTC
*** Bug 430597 has been marked as a duplicate of this bug. ***
Comment 20 zephyrus00jp 2021-03-18 12:10:12 UTC
Funny, I still get this under linux amd64.

> 44:03.61 GECKO(32022) --32026-- WARNING: unhandled amd64-linux syscall: 315

Doesn't valgrind 3.16.1 have this patch yet?

TIA
Comment 21 Mark Wielaard 2021-03-18 12:29:59 UTC
(In reply to zephyrus00jp from comment #20)
> Funny, I still get this under linux amd64.
> 
> > 44:03.61 GECKO(32022) --32026-- WARNING: unhandled amd64-linux syscall: 315
> 
> Doesn't valgrind 3.16.1 have this patch yet?

If your distro has backported (like Fedora) yes. Otherwise, please try the valgrind 3.17.0 RC releases.
Comment 22 Mark Wielaard 2021-10-04 09:01:32 UTC
*** Bug 369028 has been marked as a duplicate of this bug. ***
Comment 23 Mark Wielaard 2021-10-04 09:03:22 UTC
*** Bug 368919 has been marked as a duplicate of this bug. ***
Comment 24 Mark Wielaard 2021-10-04 09:03:37 UTC
*** Bug 368920 has been marked as a duplicate of this bug. ***