Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

futex does not wake #2503

Closed
vans163 opened this issue Jul 3, 2021 · 5 comments
Closed

futex does not wake #2503

vans163 opened this issue Jul 3, 2021 · 5 comments

Comments

@vans163
Copy link

vans163 commented Jul 3, 2021

Running FFMPEG inside graphene direct or sgx FUTEX_CLOCK_REALTIME is not implemented, and it causes the FUTEX to get the wrong time (notice the -1594868808) causing infinite stalls on threads.

EDIT: The issue with not waking remains but it seems that its not related to FUTEX_CLOCK_REALTIME.

[P711262:T4:ffmpeg] trace: ---- shim_futex(0x1a0f03380, FUTEX_PRIVATE|FUTEX_CLOCK_REALTIME|FUTEX_WAIT_BITSET, 0, 0x0, 0x0, -1) ...
[P711262:T8:ffmpeg] warning: Ignoring FUTEX_CLOCK_REALTIME flag
[P711262:T1:ffmpeg] trace: ---- return from shim_read(...) = 0x8000
[P711262:T1:ffmpeg] trace: ---- shim_futex(0x1a0f03bc4, FUTEX_PRIVATE|FUTEX_WAKE, 1, 0x0, 0x1a0f03b98, -1594868808) ...
[P711262:T1:ffmpeg] trace: ---- return from shim_futex(...) = 0x1
[P711262:T10:ffmpeg] trace: ---- return from shim_futex(...) = 0x0
[P711262:T1:ffmpeg] trace: ---- shim_clock_gettime(1, 0x1a89536f0) = 0x0
[P711262:T1:ffmpeg] trace: ---- shim_futex(0x1a0f030c0, FUTEX_PRIVATE|FUTEX_WAKE, 1, 0x0, 0x1a0f03098, -1594871624) ...
[P711262:T1:ffmpeg] trace: ---- return from shim_futex(...) = 0x1
[P711262:T2:ffmpeg] trace: ---- return from shim_futex(...) = 0x0
[P711262:T1:ffmpeg] trace: ---- shim_clock_gettime(1, 0x1a89536f0) = 0x0
[P711262:T1:ffmpeg] trace: ---- shim_pselect6(1, 0x1a89523d0, 0x0, 0x0, 0x1a8952380, 0x0) ...
[P711262:T1:ffmpeg] trace: ---- return from shim_pselect6(...) = 0x1
[P711262:T1:ffmpeg] trace: ---- shim_read(0, 0x1a89523bc, 0x1) ...
[P711262:T1:ffmpeg] trace: ---- return from shim_read(...) = 0x1 

Running outside graphene notice the signed int max value for the futex.

   520.702 ( 0.002 ms): ffmpeg/1611 futex(uaddr: 0x55d35291fa08, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
   520.706 (         ): ffmpeg/1611 futex(uaddr: 0x55d35291f9a0, op: WAIT_BITSET|PRIVATE_FLAG|CLOCK_REALTIME, val3: MATCH_ANY) ...
   523.278 ( 0.005 ms): ffmpeg/1612 futex(uaddr: 0x55d35291fb68, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
   518.458 ( 6.058 ms): ffmpeg/1610  ... [continued]: futex())                                            = 0
   523.285 (         ): ffmpeg/1612 futex(uaddr: 0x55d35291fb00, op: WAIT_BITSET|PRIVATE_FLAG|CLOCK_REALTIME, val3: MATCH_ANY) ...
   526.510 ( 0.002 ms): ffmpeg/1610 futex(uaddr: 0x55d35291f8a8, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
   526.513 (         ): ffmpeg/1610 futex(uaddr: 0x55d35291f844, op: WAIT_BITSET|PRIVATE_FLAG|CLOCK_REALTIME, val3: MATCH_ANY) ...
   524.484 ( 0.007 ms): ffmpeg/1609 futex(uaddr: 0x55d35291f840, op: WAKE|PRIVATE_FLAG, val: 1)           = 1
   526.393 ( 0.007 ms): ffmpeg/1609 futex(uaddr: 0x55d35291f9a0, op: WAKE|PRIVATE_FLAG, val: 1)           = 1
   520.706 ( 5.696 ms): ffmpeg/1611  ... [continued]: futex())                                            = 0
   526.404 (         ): ffmpeg/1611 futex(uaddr: 0x55d35291fa08, op: WAIT|PRIVATE_FLAG, val: 2)        ...
   526.407 ( 0.002 ms): ffmpeg/1609 futex(uaddr: 0x55d35291fa08, op: WAKE|PRIVATE_FLAG, val: 1)           = 1
   526.404 ( 0.006 ms): ffmpeg/1611  ... [continued]: futex())                                            = 0
   528.647 ( 0.006 ms): ffmpeg/1611 futex(uaddr: 0x55d35291fa08, op: WAKE|PRIVATE_FLAG, val: 1)           = 0
   528.654 (         ): ffmpeg/1611 futex(uaddr: 0x55d35291f9a4, op: WAIT_BITSET|PRIVATE_FLAG|CLOCK_REALTIME, val3: MATCH_ANY) ...
   529.458 ( 0.006 ms): ffmpeg/1609 write(fd: 2</dev/pts/0>, buf: 0x7fff57160904, count: 81)              = 81
   529.559 ( 0.004 ms): ffmpeg/1609 futex(uaddr: 0x55d35291fb00, op: WAKE|PRIVATE_FLAG, val: 1)           = 1
   523.285 ( 6.279 ms): ffmpeg/1612  ... [continued]: futex())                                            = 0
   529.566 (         ): ffmpeg/1612 futex(uaddr: 0x55d35291fb68, op: WAIT|PRIVATE_FLAG, val: 2)        ...
   529.569 ( 0.002 ms): ffmpeg/1609 futex(uaddr: 0x55d35291fb68, op: WAKE|PRIVATE_FLAG, val: 1)           = 1
   529.566 ( 0.005 ms): ffmpeg/1612  ... [continued]: futex())                                            = 0
   526.513 ( 6.165 ms): ffmpeg/1610  ... [continued]: futex())                                            = 0
   532.681 (         ): ffmpeg/1610 futex(uaddr: 0x55d35291f8a8, op: WAIT|PRIVATE_FLAG, val: 2)        ...
   532.665 ( 0.010 ms): ffmpeg/1609 futex(uaddr: 0x55d35291f844, op: WAKE|PRIVATE_FLAG, val: 1)           = 1
   532.681 ( 0.540 ms): ffmpeg/1610  ... [continued]: futex())                                            = 0
   533.215 ( 0.004 ms): ffmpeg/1609 futex(uaddr: 0x55d35291f8a8, op: WAKE|PRIVATE_FLAG, val: 1)           = 1
   535.520 ( 0.009 ms): ffmpeg/1609 futex(uaddr: 0x55d35291f9a4, op: WAKE|PRIVATE_FLAG, val: 1)           = 1
   528.654 ( 6.935 ms): ffmpeg/1611  ... [continued]: futex())                                            = 0
   535.595 (         ): ffmpeg/1611 futex(uaddr: 0x55d35291fa08, op: WAIT|PRIVATE_FLAG, val: 2)        ...
   535.634 (         ): ffmpeg/1610 futex(uaddr: 0x55d35291fb34, op: WAIT_BITSET|PRIVATE_FLAG|CLOCK_REALTIME, val3: MATCH_ANY) ...
   535.717 ( 0.003 ms): ffmpeg/1612 futex(uaddr: 0x55d35291fb34, op: WAKE|PRIVATE_FLAG, val: 2147483647)  = 1
@dimakuv
Copy link

dimakuv commented Jul 5, 2021

Looks like a question to @boryspoplawski

@boryspoplawski
Copy link
Contributor

Running FFMPEG inside graphene direct or sgx FUTEX_CLOCK_REALTIME is not implemented, and it causes the FUTEX to get the wrong time (notice the -1594868808) causing infinite stalls on threads.

In your trace -1594868808 is the last argument to futex, which is unused (ignored) in FUTEX_WAKE.
Graphene implements only one clock, so ignoring FUTEX_CLOCK_REALTIME should be safe (as application cannot get different times for different clocks).

@vans163
Copy link
Author

vans163 commented Jul 5, 2021

Running FFMPEG inside graphene direct or sgx FUTEX_CLOCK_REALTIME is not implemented, and it causes the FUTEX to get the wrong time (notice the -1594868808) causing infinite stalls on threads.

In your trace -1594868808 is the last argument to futex, which is unused (ignored) in FUTEX_WAKE.
Graphene implements only one clock, so ignoring FUTEX_CLOCK_REALTIME should be safe (as application cannot get different times for different clocks).

Okay thanks, it seems the issue stems from something else then (not related to FUTEX_CLOCK_REALTIME).

@vans163 vans163 changed the title FUTEX_CLOCK_REALTIME applications get wrong time futex does not wake Jul 5, 2021
@boryspoplawski
Copy link
Contributor

Unfortunately there seems to be nothing wrong in the logs you've provided, so I won't be able to help more without more information.

@mkow
Copy link
Member

mkow commented Jul 15, 2021

I believe there's no problem with futex syscall here, and FFMPEG troubles were caused by #2553, so I'm closing this issue.
@vans163 Feel free to reopen if you think that there are still some problems with futexes.

@mkow mkow closed this as completed Jul 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants