Bug 400593 - In Coregrind, use statx for some internal syscalls if [f]stat[64] fail
Summary: In Coregrind, use statx for some internal syscalls if [f]stat[64] fail
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-02 15:36 UTC by Aleksandar Rikalo
Modified: 2019-08-23 20:28 UTC (History)
3 users (show)

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


Attachments
Use statx in Coregrind (7.80 KB, patch)
2018-11-02 15:36 UTC, Aleksandar Rikalo
Details
Use statx in Coregrind (9.33 KB, patch)
2019-08-16 15:18 UTC, Aleksandar Rikalo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksandar Rikalo 2018-11-02 15:36:02 UTC
Created attachment 116054 [details]
Use statx in Coregrind

Hello everyone,

We are going to implement support for nanoMIPS architecture - patches will be ready soon.
nanoMIPS has no support for [f]stat[64] syscalls, there is only statx and support for Linux 4.11+.
In order to support nanoMIPS, we need Valgrind (Coregrind) to use statx (as one of candidates) for internal purposes.

I'm suggesting this patch for the purpose, but it needs to be tested on all architectures/platforms.
It is tested on AMD64/Linux and MIPS{32,64}/Linux.

Aleksandar
Comment 1 Petar Jovanovic 2019-07-23 13:35:58 UTC
Is everyone OK with this change?
Comment 2 Petar Jovanovic 2019-08-14 17:00:10 UTC
I can see new failures with the change applied:

== 238 tests, 4 stderr failures, 4 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures ==
none/tests/bigcode                       (stdout)
none/tests/bigcode                       (stderr)
none/tests/map_unmap                     (stdout)
none/tests/map_unmap                     (stderr)
none/tests/sigstackgrowth                (stdout)
none/tests/sigstackgrowth                (stderr)
none/tests/stackgrowth                   (stdout)
none/tests/stackgrowth                   (stderr)

arch: x86_64
glibc version: 2.27

I am getting these kind of errors:

+--18001:0: aspacem segment mismatch: V's seg 1st, kernel's 2nd:
+--18001:0: aspacem   1: file 0000108000-0000108fff    4096 r-x-- SmFixed d=0x........ i=178667325 o=0       (1,64) /home/petarj/radni/valgrind/trunk/none/tests/sigstackgrowth
+--18001:0: aspacem ...: .... 0000108000-0000108fff    4096 r-x.. ....... d=0x........ i=178667325 o=0       (.) m=. /home/petarj/radni/valgrind/trunk/none/tests/sigstackgrowth
+--18001:0: aspacem sync check at m_aspacemgr/aspacemgr-linux.c:2053 (vgPlain_am_get_advisory): FAILED
+--18001:0: aspacem
+--18001:0: aspacem Valgrind: FATAL: aspacem assertion failed:
+--18001:0: aspacem   VG_(am_do_sync_check) (__PRETTY_FUNCTION__,__FILE__,__LINE__)
+--18001:0: aspacem   at m_aspacemgr/aspacemgr-linux.c:2053 (vgPlain_am_get_advisory)
+--18001:0: aspacem Exiting now.

According to the results on the valgrind-testresults mailing list, it seems these errors are already present on some arches and configurations.
Comment 3 Aleksandar Rikalo 2019-08-16 15:18:07 UTC
Created attachment 122180 [details]
Use statx in Coregrind

The patch is re-based and `Device ID` conversion is fixed.
There is no more regressions on x86 and MIPS systems which support statx.
Comment 4 Petar Jovanovic 2019-08-16 16:03:23 UTC
This version looks better, thanks.
I have just pushed it [1] after some testing, but I will leave the issue open so we can see over the weekend whether there have been regressions on other platforms or not.

[1] https://sourceware.org/git/?p=valgrind.git;a=commit;h=c6a6cf929f3e2a9bf5d7f09f334ed4d67f2d6e18
Comment 5 Philippe Waroquiers 2019-08-17 06:13:55 UTC
(In reply to Petar Jovanovic from comment #4)
> This version looks better, thanks.
> I have just pushed it [1] after some testing, but I will leave the issue
> open so we can see over the weekend whether there have been regressions on
> other platforms or not.
> 
> [1]
> https://sourceware.org/git/?p=valgrind.git;a=commit;
> h=c6a6cf929f3e2a9bf5d7f09f334ed4d67f2d6e18

Would be good to add the bug nr in NEWS fixed list.

Thanks
Comment 6 Petar Jovanovic 2019-08-19 14:40:48 UTC
(In reply to Philippe Waroquiers from comment #5)
> (In reply to Petar Jovanovic from comment #4)
> > This version looks better, thanks.
> > I have just pushed it [1] after some testing, but I will leave the issue
> > open so we can see over the weekend whether there have been regressions on
> > other platforms or not.
> > 
> > [1]
> > https://sourceware.org/git/?p=valgrind.git;a=commit;
> > h=c6a6cf929f3e2a9bf5d7f09f334ed4d67f2d6e18
> 
> Would be good to add the bug nr in NEWS fixed list.
> 
> Thanks

Done. I just wanted to see results on the mailing list before add it to the NEWS.
Comment 7 Mark Wielaard 2019-08-23 20:28:37 UTC
One more followup for linux-arm64:

commit d2658f71c3d09034068bc6f7a115f44ce9535ad8
Author: Mark Wielaard <mark@klomp.org>
Date:   Fri Aug 23 22:17:57 2019 +0200

    arm64 fixup for statx support on older kernels
    
    Turns out (older) arm64 linux kernels don't have statx, but also not
    stat64 and no stat syscalls.  It uses fstatat instead. The new statx
    patch also added a check for stat.  So That needs a special case for
    arm64.
    
    Follow up for bug #400593.