lgi-devs / lgi

Dynamic Lua binding to GObject libraries using GObject-Introspection
MIT License
440 stars 70 forks source link

tests: corocbk.lua: terminate MainLoop on exit #303

Open sfesenko opened 2 years ago

sfesenko commented 2 years ago

Test (whole process) fails for luajit2.1 without correct termination of main loop

psychon commented 1 year ago

How is this code even reached? By the time this call to g_main_loop_quit() is executed, g_main_loop_run() must already have terminated, so... the main loop isn't running?

Put differently: Is this really fixing a bug in the test or is this just modifying the test to mask "the real problem"?

sfesenko commented 1 year ago

IMO, error doesn't terminate main loop, so after pcall program has illegal state (exit from main loop without terminating it).

psychon commented 1 year ago

So, in other news, the whole test is invalid and needs to be deleted? (Or better: Replaced with something else that still tests whatever this test is supposed to test, but without being invalid)

What exactly does "doesn't terminate main loop" mean? Obviously g_main_loop_run() is no longer running...?

sfesenko commented 1 year ago

What exactly does "doesn't terminate main loop" mean? Obviously g_main_loop_run() is no longer running...?

I guess, without g_main_loop_quit() call main loop is still active, so whole program enters abnormal state (since it exit main loop without g_main_loop_quit() call)

So, in other news, the whole test is invalid and needs to be deleted?

All tests are executed in the same context, so each test should be responsible for cleaning up allocated resources. And, main loop must be terminated by g_main_loop_quit() before exit corocbk.rethrow()

To sum up: