Re: [Vala] Fwd: Possible bug of seg fault when array returned



Like Daniel said you're accessing uninitialized objects with the foreach
statement.
Replacing *Temp2[] x = new Temp2[50];* with *Temp2[] x = new Temp2[2];* will
work.
If you want to get a better picture of what's going on, I recommend
compiling it to c code (valac -C), you can then see that the foreach
statement is translated to a for loop that iterates 50 times.

     Jonathan Moerman

2016-02-24 16:15 GMT+01:00 Daniel Espinosa <esodan gmail com>:

In your code you just initialize objects at 4 and 6, then when try iterates
over first ones you access to uninitialized objects.

Try to create an empty array {} then use += to add objects to it. This way
you should create smallest array with all its members initialized.
El feb. 24, 2016 8:21 AM, "Megh Parikh" <meghprkh gmail com> escribió:

When returning an array of objects from a method (static in my case),
trying  to access the objects gives segfault. This may be a bug as I
think the objects are freed before the code ends but I dont know for
sure so I am posting in mailing list instead of Bugzilla

Dummy code (25 line)  :
https://gist.github.com/meghprkh/0147641f7b57466def19

Regards,
Megh Parikh
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list

_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]