Bug 80594 - event loop test fails from time to time
Summary: event loop test fails from time to time
Status: RESOLVED FIXED
Alias: None
Product: Wayland
Classification: Unclassified
Component: wayland (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Wayland bug list
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-27 12:29 UTC by Marek Chalupa
Modified: 2014-08-19 11:38 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Add asserts, fix indentation (21 bytes, patch)
2014-08-19 10:31 UTC, Marek Chalupa
Details | Splinter Review
Sleep 15ms before entering epoll_wait (1.89 KB, patch)
2014-08-19 10:32 UTC, Marek Chalupa
Details | Splinter Review
Add asserts, fix indentation (1.22 KB, patch)
2014-08-19 10:35 UTC, Marek Chalupa
Details | Splinter Review

Description Marek Chalupa 2014-06-27 12:29:26 UTC
Hi,

it's very rare event, I noticed it by accident, so I tried this:

  $ while ./event-loop-test; do ; done

Sometimes it takes time, but the result is:

test "event_loop_destroy":      exit status 0, pass.
lt-event-loop-test: tests/event-loop-test.c:258: event_loop_timer_updates: Assertion `context.count == 2' failed.
test "event_loop_timer_updates":        signal 6, fail.
test "event_loop_timer":        exit status 0, pass.
test "event_loop_signal":       exit status 0, pass.
test "event_loop_free_source_with_data":        exit status 0, pass.
test "event_loop_post_dispatch_check":  exit status 0, pass.
6 tests, 5 pass, 1 fail

I tried it on fedora and arch linux, master branch of wayland.

Regards,
Marek Chalupa
Comment 1 Marek Chalupa 2014-08-19 10:30:15 UTC
Hi,

looked a little bit into it. This occasional failure is caused by epoll_wait catching only one timer source. Since we have not guaranteed that both timers will expire exactly at the same time, it may happen that epoll_wait will return
before the later timer expires, having only one fd ready.

The best fix IMO (tried) would be to add getter for source's fd and poll on the fd until it's ready for reading. This way we could wait for both timers to expire before calling wl_event_loop_dispatch. This would require change in libwayland, though.

The solution I therefore chose is just simply sleep a while before entering the epoll_wait, so that we are "sure" that both timers expired.

Along with the patch solving this, I'm attaching patch that adds some asserts into this test and fixes wrong indentation.

Cheers,
Marek
Comment 2 Marek Chalupa 2014-08-19 10:31:14 UTC
Created attachment 104879 [details] [review]
Add asserts, fix indentation
Comment 3 Marek Chalupa 2014-08-19 10:32:26 UTC
Created attachment 104880 [details] [review]
Sleep 15ms before entering epoll_wait
Comment 4 Marek Chalupa 2014-08-19 10:35:39 UTC
Created attachment 104881 [details] [review]
Add asserts, fix indentation

Oops, seems like loading the patch failed. This is the same patch loaded again.
Comment 5 Pekka Paalanen 2014-08-19 11:38:54 UTC
Both patches pushed.

commit b24fa4c8216e3f0f7b644c7b8c6949925f19ada9
Author: Marek Chalupa <mchqwerty@gmail.com>
Date:   Tue Aug 19 12:03:48 2014 +0200

    tests: fix event_loop_timer_updates


commit 12ec657014d7fda1c9ebb0358a72bd1a4b5d868c
Author: Marek Chalupa <mchqwerty@gmail.com>
Date:   Tue Aug 19 10:34:52 2014 +0200

    tests: event_loop_timer_updates - add asserts and fix indentation


I assume this fixes the issue.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.