Segmentation fault and error when referencing a constant structure or symbol
Submitted by pancake
Link to original bug (#618933)
Description
Created attachment 161277 gdb session of segfault
The following code makes valac segfault:
/* valac --pkg r_lib plugin.vala --library=plugin */ using Radare;
[CCode (has_target = false)] bool mycall(void *user, string cmd) { print ("Hello World from Vala!\n"); return true; }
const RCmdHandle plugin = { "my plugin", mycall };
const RCmdStruct radare_plugin = { RLibType.CMD, ref main // plugin };
By defining it locally, it compiles and runs fine.
void main() { RCmdHandle local_plugin = { "my plugin", mycall }; RCmdStruct local_radare_plugin = { RLibType.CMD, ref local_plugin }; }
I attach the gdb session with the segmentation fault and the patch that fixes the compiler to support this kind of references.
Maybe we should handle other conditions, so this patch needs review.
Attachment 161277, "gdb session of segfault":
gdb-session.txt