<< July 4, 2008 >>
one happy camper
someone at work mentioned vala this week, or at least asked what i thought about it, so i had to mention how awesome gom is, with the caveat that it is broken right now and crashes when the GC runs. i basically haven't touched it since april, when i first hit this bug, and have had no luck tracking it down.
and that's pretty embarrassing. so i tried to fix it, now that i have unpacking to put off.
patch one wasn't too difficult to track down once i started reading some of the code where i was getting the failed assertion. it was the classic passing an int instead of a jsval (even though my getter func doesn't look at that field; it just returns the "tiny" id):
Index: src/libgom/gomjsobject.c =================================================================== --- src/libgom/gomjsobject.c (revision 57) +++ src/libgom/gomjsobject.c (working copy) @@ -602,7 +613,7 @@ JS_DefinePropertyWithTinyId (cx, ctor, &enums->values[i].value_name[4], enums->values[i].value, - enums->values[i].value, + INT_TO_JSVAL(enums->values[i].value), gom_js_object_get_enum, NULL, JSPROP_READONLY | JSPROP_PERMANENT); }
for the other, i pulled out all the stops, from hardware watchpoints to malloc debuggers, to that awesome gdb trick, to not installing a linux vm to use valgrind and refdbg on. i went back to the tried-and-true method of littering code with printfs, and narrowed it down to someting with the Event.target field. eventually i realized that while i had written a great finalizer for my base class, none of the subclasses chained up the finalize call, which led me to return dirty, used, and freed objects later. my classes have a lot of this now:
Index: src/libgom/gomjsevent.c =================================================================== --- src/libgom/gomjsevent.c (revision 57) +++ src/libgom/gomjsevent.c (working copy) @@ -34,6 +34,12 @@ #include <glib.h> +static void +gom_js_event_finalize (JSContext *cx, JSObject *obj) +{ + GomJSObjectClass.finalize (cx, obj); +} + JSClass GomJSEventClass = { "Event", JSCLASS_NEW_ENUMERATE, @@ -44,7 +50,7 @@ (JSEnumerateOp)gom_js_object_enumerate, JS_ResolveStub, JS_ConvertStub, - JS_FinalizeStub + gom_js_event_finalize }; static JSPropertySpec gom_js_event_props[] = { { NULL } };
tomorrow, instead of unpacking my dishes and glasses so that i could make dinner, i will remove all the cruft from my tree, and finally make that third release i've been wanting to do for three months.
also, if i didn't fix this bug i don't think my mind would let me sleep tonight, so i am doubly excited. wooooo WOOOOOOOOOOOO!