After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 762819 - Async method - overriding method returning a null-terminated array - leads to invalid C
Async method - overriding method returning a null-terminated array - leads to...
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Async
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2016-02-28 13:47 UTC by Richard Wiedenhöft
Modified: 2016-11-07 14:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase for the bug (477 bytes, text/x-vala)
2016-02-28 13:47 UTC, Richard Wiedenhöft
  Details
Patch (1.26 KB, patch)
2016-02-28 17:28 UTC, Richard Wiedenhöft
none Details | Review
Patch (1.26 KB, patch)
2016-02-28 17:56 UTC, Richard Wiedenhöft
none Details | Review
Add test case to tests/ (1.36 KB, patch)
2016-02-28 18:11 UTC, Ben
none Details | Review
add test case to tests/ (1.37 KB, patch)
2016-02-28 20:41 UTC, Ben
none Details | Review
Fix broken destruction of null-terminated arrays in async data structs (2.56 KB, patch)
2016-11-07 13:57 UTC, Rico Tzschichholz
committed Details | Review

Description Richard Wiedenhöft 2016-02-28 13:47:42 UTC
Created attachment 322577 [details]
Testcase for the bug

When a class defines an abstract method with "[CCode (array_length = false, array_null_terminated = true)]" attribute any method in a subclass overriding it produces invalid C code:

/home/richard/src/valatest/test.vala.c:145:60: error: ‘FooGetStringAsyncData {aka struct _FooGetStringAsyncData}’ has no member named ‘result_length1’
  _data_->result = (_vala_array_free (_data_->result, _data_->result_length1, (GDestroyNotify) g_free), NULL);
Comment 1 Richard Wiedenhöft 2016-02-28 15:42:28 UTC
Commenting out valagasyncmodule.vala:127-128 solves the problem but introduces a memory leak obviously.

Evil code:
    var v = new LocalVariable (m.return_type, ".result");
    ccode.add_expression (destroy_local (v));
Comment 2 Richard Wiedenhöft 2016-02-28 17:28:15 UTC
Created attachment 322595 [details] [review]
Patch
Comment 3 Richard Wiedenhöft 2016-02-28 17:56:14 UTC
Created attachment 322598 [details] [review]
Patch

Fix coding style
Comment 4 Ben 2016-02-28 18:11:38 UTC
Created attachment 322602 [details] [review]
Add test case to tests/
Comment 5 Ben 2016-02-28 20:41:38 UTC
Created attachment 322606 [details] [review]
add test case to tests/

fix test coding style
Comment 6 Luca Bruno 2016-03-01 16:47:34 UTC
Looks like gdbus has similar code. I wonder if we have a better way to get a GLibValue consistent with the result var definition.
Comment 7 Luca Bruno 2016-03-01 16:53:16 UTC
What about get_local_cvalue(m.result_var) ?
Comment 8 Rico Tzschichholz 2016-11-07 13:57:03 UTC
Created attachment 339253 [details] [review]
Fix broken destruction of null-terminated arrays in async data structs
Comment 9 Rico Tzschichholz 2016-11-07 14:19:34 UTC
Attachment 339253 [details] pushed as 14cb50a - Fix broken destruction of null-terminated arrays in async data structs