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 642885 - Generated signature for local_command_line() vfunc, has one extra parameter.
Generated signature for local_command_line() vfunc, has one extra parameter.
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Code Generator
0.22.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks: 641100
 
 
Reported: 2011-02-21 16:46 UTC by Patricia Santana Cruz
Modified: 2018-05-22 13:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case app (1.43 KB, text/x-vala)
2013-09-27 09:57 UTC, Evgeny Bobkin
Details

Description Patricia Santana Cruz 2011-02-21 16:46:15 UTC
The virtual function local_command_line() signature in the .vapi file is:
public virtual bool local_command_line 
([CCode (array_length = false, array_null_terminated = true)]
string[] arguments,
int exit_status);

The signature in the gtk3 documentation for the same function is: g_application_real_local_command_line
(GApplication   *application,
gchar ***arguments,
int *exit_status)

I see two different problems:
FIRST PROBLEM:
When overriding the local_command_line virtual() function in my .vala file, the related generated code is:
static gboolean cheese_main_real_local_command_line
(GApplication* base,
gchar** arguments,
int arguments_length1,
gint exit_status)"

This generated function, has one argument more (int arguments_length1) which might not be there.

SECOND PROBLEM:
In the signature of the same function, in the .vapi files, the exit argument should be and out argument, that means: out int exit_status
Comment 1 Jürg Billeter 2011-02-22 12:59:35 UTC
commit 519d354ea4a8c508a46052be3ad60aab14a7898b
Author: Jürg Billeter <j@bitron.ch>
Date:   Tue Feb 22 13:55:20 2011 +0100

    gio-2.0: Fix g_application_local_command_line binding
    
    Fixes bug 642885.

This commit fixes gchar ** vs. gchar *** and gint vs. gint * for the two parameters. However, you currently still need to explicitly annotate the parameter as null-terminated to avoid the extra parameter. This should get fixed as well but is easy to workaround for now:


        public override bool local_command_line ([CCode (array_length = false, array_null_terminated = true)] ref unowned string[] arguments, out int exit_status) {
                ...
        }
Comment 2 Patricia Santana Cruz 2011-02-22 14:20:18 UTC
I applied the changes in the .vapi file and used the workaround you suggested, but when building, I get the following error in valac:

ERROR:valaccodearraymodule.c:939:vala_ccode_array_module_real_get_array_length_cvalue: assertion failed: (_tmp20_)
/bin/sh: line 1: 20560 Aborted                 (core dumped) /opt/gnome/bin/valac --thread --vapidir vapi --pkg config --pkg gtk+-3.0 --pkg gmodule-2.0 --pkg gee-1.0 --pkg clutter-1.0 --pkg clutter-gtk-1.0 --pkg gstreamer-0.10 --pkg libcanberra-gtk --pkg libcanberra --pkg eogthumbnav --pkg cheese-thumbview --pkg cheese-common --pkg clutter-tablelayout -C cheese-main.vala cheese-window.vala cheese-countdown.vala cheese-effects-manager.vala cheese-preferences.vala thumbview/cheese-thumb-view.c thumbview/cheese-thumbnail.c thumbview/eog-thumb-nav.c
Comment 3 Luca Bruno 2011-07-28 07:13:33 UTC
Can you please provide a test case?
Comment 4 Murray Cumming 2012-02-10 09:03:57 UTC
Patricia, did you solve this in the meantime? If not, maybe you can provide the test case.
Comment 5 Evgeny Bobkin 2013-09-27 09:57:00 UTC
Created attachment 255907 [details]
test case app

test case is attached

if one ovrrides it like: (without a workaround)

protected override bool local_command_line (ref unowned string[] arguments, out int exit_status) {

...

option_context.parse (ref arguments);

...
}

it leads to a segmentation fault
Comment 6 Luca Bruno 2013-09-29 15:42:29 UTC
commit ebfe7b7411f413a8631fec22e704a0d8921f4417
Author: Luca Bruno <lucabru@src.gnome.org>
Date:   Sun Sep 29 17:35:47 2013 +0200

    codegen: Inherit array_{length,null_terminated} from base parameter
    
    First commit to start inheriting ccode attributes of parameters
    from base parameters of base methods.
    
    Partially fixes bug 642885.

Now the code does not need the additional CCode when overriding. Next thing to fix is the "unowned string[] args = arguments;" workaround.
Comment 7 Evan Nemerson 2013-09-29 16:52:29 UTC
ebfe7b74 seems to be causing an error when attempting to build valac.  Someone reported it on IRC, and I can reproduce (with a fresh checkout):


  VALAC  arraylist.vala collection.vala hashmap.vala hashset.vala iterable.vala mapiterator.vala iterator.vala list.vala map.vala set.vala
**
ERROR:arraylist.c:384:vala_array_list_real_get: assertion failed: (index >= 0 && index < _size)
/bin/sh: line 1: 15611 Aborted                 (core dumped) /opt/gnome/bin/valac --disable-version-header -C --vapidir ./../vapi --pkg gobject-2.0 -H valagee.h --library gee arraylist.vala collection.vala hashmap.vala hashset.vala iterable.vala mapiterator.vala iterator.vala list.vala map.vala set.vala
make[2]: *** [gee.vala.stamp] Error 134
Comment 8 Jürg Billeter 2013-09-29 17:51:05 UTC
(In reply to comment #7)
> ebfe7b74 seems to be causing an error when attempting to build valac.  Someone
> reported it on IRC, and I can reproduce (with a fresh checkout):

I've pushed a revert.
Comment 9 Luca Bruno 2013-09-29 18:03:11 UTC
commit f3aeabaf16a5e9a9ad0aa5d64b18652c203c602e
Author: Luca Bruno <lucabru@src.gnome.org>
Date:   Sun Sep 29 17:35:47 2013 +0200

    codegen: Inherit array_{length,null_terminated} from base parameter
    
    First commit to start inheriting ccode attributes of parameters
    from base parameters of base methods.
    
    Partially fixes bug 642885.

Attempt #2.
Comment 10 Luca Bruno 2013-09-30 18:44:16 UTC
Passing "arguments" directly to option_context.parse() must error out, because there's no storage for the length. So that is actually not a workaround, it's the correct way to write the code.
Comment 11 GNOME Infrastructure Team 2018-05-22 13:55:47 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/170.