Page MenuHomePhabricator

efl-csharp: fix resource deallocation causing errors everywhere
ClosedPublic

Authored by vitor.sousa on Mar 20 2019, 12:28 PM.

Details

Summary

This commit mainly fixes errors caused by deallocating resources in the garbage
collector thread. Using ecore_main_loop_thread_safe_call_async to queue
resource deallocation in the main thread seems to solve it.

Also, some efl_ref calls are added in places they were missing, mainly
objects that unref in the destructor thus taking ownership if efl_ref is not
called.

Also fix improper resource deallocation in tests that were causing it to crash,
enabling it to call Efl.All.Shutdown again. This allocation and the deallocation
process was moved from the Eo class constructor to static class methods that are
called in the test 'set up' and 'tear down' methods.

Queuing resource deallocation in the main thread make it mandatory that tests
call Efl.App.AppMain.Iterate() if they want to check proper resource
deallocation (like TestFunctionPointers.set_callback_inherited_called_from_c).

Extras:
Remove duplicated declaration of 'eflcustomexportsmono' in meson in order to fix
some linking problems.

Remove some unused code around deallocation functions that had to be reworked.

Object allocation is now supplied with the call site information it expects
(file name and line for _efl_add_start).

Depends on D8550

Test Plan

meson test

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
vitor.sousa created this revision.Mar 20 2019, 12:28 PM
vitor.sousa requested review of this revision.Mar 20 2019, 12:28 PM

@cedric I solved the concurrency problem using ecore_main_loop_thread_safe_call_async.
Eo error logs disappeared, but now the test prints a big list like this at the end of execution:

EINA ERROR: 'Invalid argument' on unlock 0x7fc693ffe980
EINA ERROR: 'Invalid argument' on lock 0x7fc693ffe980
EINA ERROR: 'Invalid argument' on unlock 0x7fc693ffe980
EINA ERROR: 'Invalid argument' on lock 0x7fc693ffe980
EINA ERROR: 'Invalid argument' on unlock 0x7fc693ffe980
EINA ERROR: 'Invalid argument' on lock 0x7fc693ffe980

Could you give it a look and check whether I am using it incorrectly or it is a problem with eina_thread?

segfaultxavi requested changes to this revision.EditedMar 21 2019, 5:27 AM
segfaultxavi added a subscriber: segfaultxavi.

I built and installed this patch (after rebasing to latest master).
All C# tutorials seems to segfault on exit. For example, the hello-world one, which only instantiates a window (console output: P279)

Source of the hello-word tutorial:
https://git.enlightenment.org/tools/examples.git/tree/tutorial/csharp/hello-world/src/hello-world.cs

This revision now requires changes to proceed.Mar 21 2019, 5:27 AM

I built and installed this patch (after rebasing to latest master).
All C# tutorials seems to segfault on exit. For example, the hello-world one, which only instantiates a window (console output: P279)

Source of the hello-word tutorial:
https://git.enlightenment.org/tools/examples.git/tree/tutorial/csharp/hello-world/src/hello-world.cs

The issue seems to be related to event handlers being called on the C# instance after it was destroyed, as the Eo instance still lives until the main loop destroys it. We are working on a fix.

vitor.sousa updated this revision to Diff 21239.Apr 5 2019, 3:29 PM

rebase and adds D8550 as a dependency

vitor.sousa updated this revision to Diff 21240.Apr 5 2019, 3:37 PM
vitor.sousa edited the summary of this revision. (Show Details)

fix previous update submitting to much code

lauromoura accepted this revision.Apr 5 2019, 3:39 PM
This revision was not accepted when it landed; it landed in state Needs Review.Apr 5 2019, 3:58 PM
This revision was automatically updated to reflect the committed changes.