multi-part CMOD with storage dumps core
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=3912
Reported by BW, Riverweb hww3@riverweb.com
When writing modules made up of multiple cmod files, the top level module class has to have CVARs before PIKEVARS, otherwise the module will cause a segfault when loading. The following module dumps core (condensed to one file for clarity), but if the CVAR and PIKEVAR are swapped, loads properly.
module.cmod:
typedef struct
{
int t;
} OBJECT_DATA;
CVAR OBJECT_DATA *object_data;
PIKEVAR int i;
pike_init_pam_main()
{
OBJECT_DATA * dta;
dta =
(OBJECT_DATA*)malloc(sizeof(OBJECT_DATA));
if (!dta)
Pike_error("init_test: Out of memory!\n");
THIS->object_data = dta;
}
pike_exit_pam_main()
{
if(THIS->object_data)
{
free(THIS->object_data);
}
}
void pike_module_init()
{
INIT
pike_init_pam_main();
}
void pike_module_exit()
{
EXIT
pike_exit_pam_main();
}