Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH 1/1] test: drop invalid assert from swim test transport
@ 2019-04-29 23:27 Vladislav Shpilevoy
  2019-04-29 23:27 ` [tarantool-patches] " Vladislav Shpilevoy
  0 siblings, 1 reply; 2+ messages in thread
From: Vladislav Shpilevoy @ 2019-04-29 23:27 UTC (permalink / raw)
  To: tarantool-patches

The assertion was checking that a next event object is not the
same as the previous, but

    1) the previous was deleted already to this moment;
    2) comparison was done by pointer

The first problem would be enough to drop it. The second is
already curious - looks like after the old event was deleted,
the next event was allocated right on the same memory. This is
why their pointers are equal and the assertion fails.

For example, swim_timer_event_process() - it deletes the event
object and calls ev_invoke() which can generate a new event on
the just freed memory.
---
 test/unit/swim_test_ev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/test/unit/swim_test_ev.c b/test/unit/swim_test_ev.c
index 135f20107..3c2eae039 100644
--- a/test/unit/swim_test_ev.c
+++ b/test/unit/swim_test_ev.c
@@ -283,7 +283,7 @@ swim_ev_timer_stop(struct ev_loop *loop, struct ev_timer *base)
 void
 swim_test_ev_do_loop_step(struct ev_loop *loop)
 {
-	struct swim_event *next_e, *e = event_heap_top(&event_heap);
+	struct swim_event *e = event_heap_top(&event_heap);
 	if (e != NULL) {
 		assert(e->deadline >= watch);
 		/* Multiple events can have the same deadline. */
@@ -291,9 +291,7 @@ swim_test_ev_do_loop_step(struct ev_loop *loop)
 		say_verbose("Loop watch %f", watch);
 		do {
 			e->process(e, loop);
-			next_e = event_heap_top(&event_heap);
-			assert(e != next_e);
-			e = next_e;
+			e = event_heap_top(&event_heap);
 		} while (e != NULL && e->deadline == watch);
 	}
 }
-- 
2.20.1 (Apple Git-117)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tarantool-patches] Re: [PATCH 1/1] test: drop invalid assert from swim test transport
  2019-04-29 23:27 [tarantool-patches] [PATCH 1/1] test: drop invalid assert from swim test transport Vladislav Shpilevoy
@ 2019-04-29 23:27 ` Vladislav Shpilevoy
  0 siblings, 0 replies; 2+ messages in thread
From: Vladislav Shpilevoy @ 2019-04-29 23:27 UTC (permalink / raw)
  To: tarantool-patches

Pushed to the master as trivial.

On 30/04/2019 02:27, Vladislav Shpilevoy wrote:
> The assertion was checking that a next event object is not the
> same as the previous, but
> 
>     1) the previous was deleted already to this moment;
>     2) comparison was done by pointer
> 
> The first problem would be enough to drop it. The second is
> already curious - looks like after the old event was deleted,
> the next event was allocated right on the same memory. This is
> why their pointers are equal and the assertion fails.
> 
> For example, swim_timer_event_process() - it deletes the event
> object and calls ev_invoke() which can generate a new event on
> the just freed memory.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-29 23:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-29 23:27 [tarantool-patches] [PATCH 1/1] test: drop invalid assert from swim test transport Vladislav Shpilevoy
2019-04-29 23:27 ` [tarantool-patches] " Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox