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 626397 - Incorrect enum / switch usage causing segfault in 0.9.4 (and previous)
Incorrect enum / switch usage causing segfault in 0.9.4 (and previous)
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.9.x
Other Linux
: Urgent critical
: ---
Assigned To: Vala maintainers
Vala maintainers
crash-on-invalid-code test-case
Depends on:
Blocks:
 
 
Reported: 2010-08-08 21:33 UTC by Dru Moore
Modified: 2010-08-20 07:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix the issue (782 bytes, patch)
2010-08-10 18:17 UTC, carlo.teubner
none Details | Review

Description Dru Moore 2010-08-08 21:33:56 UTC
This came up because of a stupid error in my code but, incorrect (i.e. stupid!) use of an enum in a switch statement is segfaulting the code generator on both 64bit x86 and armel platforms. As I say it's clearly stupid on behalf of the programmer but it should not compile rather than segfault I guess.

Below is the smallest example I could devise that exhibits the segfault in 0.9.4, but the behaviour is consistent as complexity grows.


public static int main(string[] args) {
  Test test = {TheEnumerator.ONE};
  switch (TheEnumerator) { // clearly should be test.the_enumerator !
    case TheEnumerator.ONE:
      break;
    default:
      break;
  }
  return 0;
}

public enum TheEnumerator {
  ONE
}

public struct Test {
  TheEnumerator the_enumerator;
}
Comment 1 carlo.teubner 2010-08-10 18:17:06 UTC
Created attachment 167538 [details] [review]
Patch to fix the issue

Attached patch fixes the issue. Just a missing null check.
Comment 2 Jürg Billeter 2010-08-20 07:53:42 UTC
commit 3b68bb5b88006a5a2a704b593e9b9e7e878da8db
Author: Carlo Teubner <carlo.teubner@gmail.com>
Date:   Fri Aug 20 09:52:25 2010 +0200

    Fix crash on invalid switch expression
    
    Fixes bug 626397.