File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
packages/orchestrator/pkg/sandbox/uffd/userfaultfd Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,19 @@ func (u *Userfaultfd) Serve(
253253 noDataCounter .Log (ctx )
254254 eagainCounter .Log (ctx )
255255
256+ // Wait for all in-flight fault goroutines before processing REMOVE events.
257+ // A goroutine from the previous batch could still be executing setState(faulted)
258+ // at line 326 after its UFFDIO_COPY returned. If we process a REMOVE for the same
259+ // page before that goroutine finishes, the goroutine's setState(faulted) would
260+ // overwrite the removed state we just set.
261+ if len (removes ) > 0 {
262+ if waitErr := u .wg .Wait (); waitErr != nil {
263+ u .logger .Error (ctx , "UFFD serve error waiting for goroutines before REMOVE" , zap .Error (waitErr ))
264+
265+ return fmt .Errorf ("failed to handle uffd: %w" , waitErr )
266+ }
267+ }
268+
256269 // First handle the UFFD_EVENT_REMOVE events
257270 for _ , rm := range removes {
258271 u .pageTracker .setState (uintptr (rm .start ), uintptr (rm .end ), removed )
You can’t perform that action at this time.
0 commit comments