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 663818 - Incorrect handling of class instances passed as 'ref' parameters with --enable-checking turned on.
Incorrect handling of class instances passed as 'ref' parameters with --enabl...
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.14.x
Other Linux
: Normal major
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-11-10 23:22 UTC by clinton
Modified: 2011-11-11 20:31 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description clinton 2011-11-10 23:22:28 UTC
Steps to reproduce:

1) Compile the following short program with --enable-checking:

	public class CLASS_ONE {
		public string field_one;
		public CLASS_ONE() { field_one = "test"; }
	}
		
	/***********************************/

	public void do_something_with_class_one(ref CLASS_ONE victim) {
		victim.field_one = "test failed";
	}

	/***********************************/

	void main()
	{
		CLASS_ONE c_1 = new CLASS_ONE();
		do_something_with_class_one(ref c_1);
	}

...and attempt to run it.

Notice that an error after the following form appears:
   ** (process:2674): CRITICAL **: do_something_with_class_one: assertion `IS_CLASS_ONE (victim)' failed

Compiling down to C code (with the command valac -C --enable-checking name_of_file.vala) reveals the following code in do_something_with_class_one():

	void do_something_with_class_one (CLASS_ONE** victim) {
	   CLASS_ONE* _tmp0_;
	   gchar* _tmp1_;
	   g_return_if_fail (IS_CLASS_ONE (victim)); // <---- problem
	   _tmp0_ = *victim;
	   ...

IS_CLASS_ONE will fail, because it's expecting a pointer to a CLASS_ONE, rather than a pointer to a pointer to a CLASS_ONE.
Comment 1 Luca Bruno 2011-11-11 20:31:53 UTC
commit 3d4112da8c4359b6df9ad97a54878e8fe567c962
Author: Luca Bruno <lucabru@src.gnome.org>
Date:   Fri Nov 11 21:29:54 2011 +0100

    codegen: Fix type check of ref parameters
    
    Fixes bug 663818.

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.