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 570091 - [feb 1st trunk valac] compile gives segv in vala_data_type_get_cnam
[feb 1st trunk valac] compile gives segv in vala_data_type_get_cnam
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.5.x
Other All
: Normal critical
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-02-01 14:39 UTC by Martin Olsson
Modified: 2009-06-06 15:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
testcase (559 bytes, application/x-compressed-tar)
2009-02-01 14:40 UTC, Martin Olsson
  Details
Patch (5.11 KB, patch)
2009-03-27 19:55 UTC, Levi Bard
needs-work Details | Review
Patch (4.42 KB, patch)
2009-04-16 21:02 UTC, Levi Bard
needs-work Details | Review
Patch (4.29 KB, patch)
2009-05-13 13:29 UTC, Levi Bard
reviewed Details | Review

Description Martin Olsson 2009-02-01 14:39:23 UTC
Steps to reproduce:
1. run make on this testcase (feel free to use snippet as regression test later)
2. segv in valac inside vala_data_type_get_cnam

vala 0.5.1 does NOT exhibit this bug
vala 0.5.4 DOES exhibit this bug
vala 0.5.3 DOES exhibit this bug
vala 0.5.2 DOES exhibit this bug
vala 0.4.0 does NOT exhibit this bug

Details here:
https://bugs.launchpad.net/ubuntu/+source/vala/+bug/323943


These asserts are hit inside valac:
** (valac:15783): CRITICAL **: vala_ccode_base_module_get_temp_variable: assertion `type != NULL' failed
** (valac:15783): CRITICAL **: vala_symbol_get_name: assertion `self != NULL' failed
** (valac:15783): CRITICAL **: vala_ccode_base_module_get_variable_cexpression: assertion `name != NULL' failed
** (valac:15783): CRITICAL **: vala_ccode_assignment_construct: assertion `l != NULL' failed
** (valac:15783): CRITICAL **: vala_ccode_comma_expression_append_expression: assertion `expr != NULL' failed
** (valac:15783): CRITICAL **: vala_symbol_get_name: assertion `self != NULL' failed
** (valac:15783): CRITICAL **: vala_ccode_base_module_get_variable_cexpression: assertion `name != NULL' failed
** (valac:15783): CRITICAL **: vala_ccode_comma_expression_append_expression: assertion `expr != NULL' failed
** (valac:15783): CRITICAL **: vala_local_variable_get_variable_type: assertion `self != NULL' failed
make: *** [all] Segmentation fault (core dumped)



Here is the stack (captured with Feb 1st trunk valac):
  • #0 vala_data_type_get_cname
    at valadatatype.c line 187
  • #1 vala_ccode_base_module_append_temp_decl
    at valaccodebasemodule.c line 5055
  • #2 vala_ccode_base_module_create_temp_decl
    at valaccodebasemodule.c line 5194
  • #3 vala_statement_list_real_accept
    at valastatementlist.c line 99
  • #4 vala_block_real_accept_children
    at valablock.c line 223
  • #5 vala_ccode_base_module_real_visit_block
    at valaccodebasemodule.c line 3384
  • #6 vala_ccode_control_flow_module_real_visit_while_statement
    at valaccodecontrolflowmodule.c line 571
  • #7 vala_block_real_accept_children
    at valablock.c line 223
  • #8 vala_ccode_base_module_real_visit_block
    at valaccodebasemodule.c line 3384
  • #9 vala_ccode_method_module_real_visit_method
    at valaccodemethodmodule.c line 452
  • #10 vala_source_file_accept_children
    at valasourcefile.c line 288
  • #11 vala_ccode_base_module_real_visit_source_file
    at valaccodebasemodule.c line 825
  • #12 vala_ccode_base_module_real_emit
    at valaccodebasemodule.c line 1457
  • #13 main
    at valacompiler.c line 530
  • #0 vala_data_type_get_cname
    at valadatatype.c line 187
  • #1 vala_ccode_base_module_append_temp_decl
    at valaccodebasemodule.c line 5055
  • #2 vala_ccode_base_module_create_temp_decl
    at valaccodebasemodule.c line 5194
  • #3 vala_statement_list_real_accept
    at valastatementlist.c line 99
  • #4 vala_block_real_accept_children
    at valablock.c line 223
  • #5 vala_ccode_base_module_real_visit_block
    at valaccodebasemodule.c line 3384
  • #6 vala_ccode_control_flow_module_real_visit_while_statement
    at valaccodecontrolflowmodule.c line 571
  • #7 vala_block_real_accept_children
    at valablock.c line 223
  • #8 vala_ccode_base_module_real_visit_block
    at valaccodebasemodule.c line 3384
  • #9 vala_ccode_method_module_real_visit_method
    at valaccodemethodmodule.c line 452
  • #10 vala_source_file_accept_children
    at valasourcefile.c line 288
  • #11 vala_ccode_base_module_real_visit_source_file
    at valaccodebasemodule.c line 825
  • #12 vala_ccode_base_module_real_emit
    at valaccodebasemodule.c line 1457
  • #13 main
    at valacompiler.c line 530


Stack trace:


Other information:
Comment 1 Martin Olsson 2009-02-01 14:40:05 UTC
Created attachment 127699 [details]
testcase
Comment 2 Jürg Billeter 2009-02-20 17:10:43 UTC
Reduced test case:

public class Stack<T> {
	public T peek () throws Error 	{
		return null;
	}
}

public static void main (string[] args) {
	Stack<string> st = new Stack<string> ();
	while (st.peek ()) {
	}
}
Comment 3 Levi Bard 2009-03-27 19:55:03 UTC
Created attachment 131517 [details] [review]
Patch

Moves conditional split farther up the analysis tree for loop conditions, preventing recursing into partially-completed analysis when conditional expressions can throw errors.
Comment 4 Jürg Billeter 2009-04-15 20:24:07 UTC
Thanks for the patch. Unfortunately, removing the code that handles method calls that can throw errors can lead to incorrect code. For example, if you assign the result of a method call to a local variable, the compiler will not catch the error until after the assignment if your patch is applied. However, the assignment must not happen in the error case.
Comment 5 Levi Bard 2009-04-16 21:02:03 UTC
Created attachment 132792 [details] [review]
Patch

Reworked patch.
Comment 6 Jürg Billeter 2009-05-09 16:47:25 UTC
Thanks for the updated patch. It still causes some regressions. For example, the following test case results in an endless loop with your patch applied:

public class Stack<T> {
	static int i = 0;
        public bool peek () throws Error   {
                return (i++ == 0);
        }
}

public static void main (string[] args) {
        Stack<string> st = new Stack<string> ();
        while (st.peek ()) {
        }
}
Comment 7 Levi Bard 2009-05-13 13:29:42 UTC
Created attachment 134563 [details] [review]
Patch

Reworked again per comments.
Comment 8 Jürg Billeter 2009-06-06 15:19:47 UTC
Thanks for the update. The patch goes into the right direction by doing the transformation earlier. To avoid similar issues in the future, I'll take the patch a step further and transform all while, do, and for loops into one simple loop type without a condition. This simplifies code in semantic and flow analysis and code generation.
Comment 9 Jürg Billeter 2009-06-06 15:20:58 UTC
commit fef10859ae29c524cac6a7388759f02e26df160d
Author: Jürg Billeter <j@bitron.ch>
Date:   Sat Jun 6 17:04:02 2009 +0200

    Convert for loops into simple loops

commit a71e6e0dea67455e741ffe319f796419a3fa42fe
Author: Jürg Billeter <j@bitron.ch>
Date:   Sat Jun 6 16:20:32 2009 +0200

    Convert do loops into simple loops

commit 14cb3893cf381f6b9136eccccdba86bc42786a56
Author: Jürg Billeter <j@bitron.ch>
Date:   Sat Jun 6 15:58:44 2009 +0200

    Convert while loops into simple loops
    
    Simplifies and fixes bugs in semantic and flow analysis and code
    generation. Based on patch by Levi Bard, fixes bug 570091.