protonscr

Strange Fsync Issue

wineclosed
ValveSoftware/wine#131 · opened 2021-11-13 by liberodark · updated 2022-11-14 · 3 comments · github
Lliberodark 2021-11-13 github

Hi,

When try to use kernel patch from : https://github.com/andrealmeid/futex_waitv_patches/tree/main/5.15

And when try to build proton 6.3-8-rc3
Have this issue :

  -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -O3 -g0 -D_FORTIFY_SOURCE=1 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
dlls/ntdll/unix/fsync.c:109:45: warning: ‘struct futex_waitv’ declared inside parameter list will not be visible outside of this definition or declaration
  109 | static inline void futex_vector_set( struct futex_waitv *waitv, int *addr, int val )
      |                                             ^~~~~~~~~~~
dlls/ntdll/unix/fsync.c: In function ‘futex_vector_set’:
dlls/ntdll/unix/fsync.c:111:10: error: invalid use of undefined type ‘struct futex_waitv’
  111 |     waitv->uaddr = (uintptr_t) addr;
      |          ^~
dlls/ntdll/unix/fsync.c:112:10: error: invalid use of undefined type ‘struct futex_waitv’
  112 |     waitv->val = val;
      |          ^~
dlls/ntdll/unix/fsync.c:113:10: error: invalid use of undefined type ‘struct futex_waitv’
  113 |     waitv->flags = FUTEX_32;
      |          ^~
dlls/ntdll/unix/fsync.c:113:20: error: ‘FUTEX_32’ undeclared (first use in this function)
  113 |     waitv->flags = FUTEX_32;
      |                    ^~~~~~~~
dlls/ntdll/unix/fsync.c:113:20: note: each undeclared identifier is reported only once for each function it appears in
dlls/ntdll/unix/fsync.c:114:10: error: invalid use of undefined type ‘struct futex_waitv’
  114 |     waitv->__reserved = 0;
      |          ^~
dlls/ntdll/unix/fsync.c: At top level:
dlls/ntdll/unix/fsync.c:117:53: warning: ‘struct futex_waitv’ declared inside parameter list will not be visible outside of this definition or declaration
  117 | static inline int futex_wait_multiple( const struct futex_waitv *futexes,
      |                                                     ^~~~~~~~~~~
dlls/ntdll/unix/fsync.c: In function ‘do_single_wait’:
dlls/ntdll/unix/fsync.c:725:28: error: array type has incomplete element type ‘struct futex_waitv’
  725 |         struct futex_waitv futexes[2];
      |                            ^~~~~~~
dlls/ntdll/unix/fsync.c:725:28: warning: unused variable ‘futexes’ [-Wunused-variable]
dlls/ntdll/unix/fsync.c: In function ‘__fsync_wait_objects’:
dlls/ntdll/unix/fsync.c:756:24: error: array type has incomplete element type ‘struct futex_waitv’
  756 |     struct futex_waitv futexes[MAXIMUM_WAIT_OBJECTS + 1];
      |                        ^~~~~~~
dlls/ntdll/unix/fsync.c:756:24: warning: unused variable ‘futexes’ [-Wunused-variable]

I can build proton only if i remove patch for add futex-waitv.
@ivyl i know you have work on fsync too if you have idea ?

Update : For fix this issue have apply this patch :

diff --git a/dlls/ntdll/unix/fsync.c b/dlls/ntdll/unix/fsync.c
index 8f07ed59ae0..481ada2a596 100644
--- a/dlls/ntdll/unix/fsync.c
+++ b/dlls/ntdll/unix/fsync.c
@@ -66,9 +66,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(fsync);
 /* futex_waitv interface */

 #ifndef __NR_futex_waitv
-
 # define __NR_futex_waitv 449
+#endif
+
+#ifndef FUTEX_32
 # define FUTEX_32 2
+#endif
+
 struct futex_waitv {
     uint64_t   val;
     uint64_t   uaddr;
@@ -76,8 +80,6 @@ struct futex_waitv {
     uint32_t __reserved;
 };

-#endif
-
 #define u64_to_ptr(x) (void *)(uintptr_t)(x)

 struct timespec64

Best Regards

Iivyl 2021-11-13 github

It's because you are building Proton's wine outside of the provided container, which again is not supported. You are building with your system headers which already have __NR_futex_waitv define. fsync.c doesn't include linux/futex.h, so we wont have FUTEX_32 or struct futex_waitv available.

The correct fix is to either start including linux/futex.h but is should probably come with configure.ac changes so we can have a test for it, or just define both unconditionally.

diff --git a/dlls/ntdll/unix/fsync.c b/dlls/ntdll/unix/fsync.c
index 8f07ed59ae0..3973278e439 100644
--- a/dlls/ntdll/unix/fsync.c
+++ b/dlls/ntdll/unix/fsync.c
@@ -66,9 +66,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(fsync);
 /* futex_waitv interface */
 
 #ifndef __NR_futex_waitv
-
 # define __NR_futex_waitv 449
-# define FUTEX_32 2
+#endif
+
+#define FUTEX_32 2
 struct futex_waitv {
     uint64_t   val;
     uint64_t   uaddr;
@@ -76,8 +77,6 @@ struct futex_waitv {
     uint32_t __reserved;
 };
 
-#endif
-
 #define u64_to_ptr(x) (void *)(uintptr_t)(x)
 
 struct timespec64
Lliberodark 2021-11-13 github

Currently I don't have a better patch to offer, it's been a long time since wine-proton build and we will continue as long as possible.
Because it remains our reference wine
Thank you already for updating my patch.
And also for your indications.

Lliberodark 2022-11-14 github

Issue Fixed

Proton versions

Launch options