Thanks a ton, Jameson---you were totally right about the error. For the
record, I think this:
static jl_svec_t *ntuple_translate_data(jl_value_t **data, int n)
{
int i;
jl_value_t **protected;
JL_GC_PUSHARGS(protected, 2*n+1);
for (i = 0; i < n; i++) {
protected[i] = data[i];
protected[i+n] = NULL; // just in case
}
protected[2*n] = NULL;
jl_svec_t *snew = jl_alloc_svec(n);
protected[2*n] = (jl_value_t*) snew;
for (i = 0; i < n; i++)
protected[i+n] = jl_svecref(snew, i);
assert(jl_is_svec(snew));
for (i = 0; i < n; i++) {
assert(jl_is_svec(snew));
jl_value_t *translated = ntuple_translate(data[i]);
assert(jl_is_svec(snew));
jl_svecset(snew, i, translated);
}
JL_GC_POP();
return snew;
}
also works (mostly) and is a little simpler. The good news is I can now run
all the tests if I run normally. The bad news is that I'm still getting a
segfault only when I run under gdb. (Both are with julia-debug, too. Strange.)
I'm trying valgrind and rr. But this feels like progress, so many thanks!
--Tim