Search code examples
arraysassertionsvala

Vala compilation fails with vala_ccode_array_module_real_get_array_length_cvalue: assertion failed


I'm working on developing a library for interfacing with Pandora. I'm basing my blowfish code off of the python library, but I'm having trouble compiling it. Vala reports no errors until it tries to generate C source files. This is the error I am getting:

nathan@nathan-laptop:~/projects/libpanda$ valac --thread lib/crypto.vala -C -v
Loaded package `/usr/share/vala-0.26/vapi/glib-2.0.vapi'
Loaded package `/usr/share/vala-0.26/vapi/gobject-2.0.vapi'
lib/crypto.vala:192.42-192.60: warning: chained relational expressions are experimental
    public Blowfish(string key) requires(8 < key.length < 56){
                                         ^^^^^^^^^^^^^^^^^^^
**
ERROR:valaccodearraymodule.c:1105:vala_ccode_array_module_real_get_array_length_cvalue: assertion failed: (size != null && size.size >= dim)
Aborted (core dumped)

You can find the source code in my git repository here. I'm not sure if this is a bug with vala itself or my code. I have a feeling it has something to do with multi-dimensional arrays, as it was compiling yesterday when the sboxes were single-dimensional arrays.

EDIT: It looks like this is an issue with vala itself. It appears you cannot assign the value of a const multi-dimensional array to another variable:

public class TestClass : GLib.Object{
    public static const int[,] ff = {{1,2},{3,4}};

    public int[,] asdf;

    public TestClass(){
        asdf = TestClass.ff;
    }

    public static int main(string[] args){
        var t = new TestClass();
        return 0;
    }
}

Solution

  • As stated in my edit above, it appears you cannot assign the value of a const multi-dimensional array to another variable:

    public class TestClass : GLib.Object{
        public static const int[,] ff = {{1,2},{3,4}};
    
        public int[,] asdf;
    
        public TestClass(){
            asdf = TestClass.ff;
        }
    
        public static int main(string[] args){
            var t = new TestClass();
            return 0;
        }
    }
    

    I have filed the bug with the vala team here