dictu-lang / Dictu

Dictu is a high-level dynamically typed, multi-paradigm, interpreted programming language.
https://dictu-lang.com
MIT License
267 stars 53 forks source link

[BUG] Very strange behaviour with SQLite (I think?) #659

Closed Jason2605 closed 1 year ago

Jason2605 commented 1 year ago

Is there an existing issue for this?

Current Behavior

There seems to be very weird behaviour coming from SQLite in that a simple database (with many values) attempting to SELECT the rows and print the string ends up with a segfault. If I replace the SQLite fetch for strings with a hardcoded value it interestingly does not segfault (unsure if this is a red herring?)

case SQLITE_TEXT: {
                    //char *s = (char *)sqlite3_column_text(result.stmt, i);
                    ObjString *string = copyString(vm, "test", strlen("test"));
                    push(vm, OBJ_VAL(string));
                    writeValueArray(vm, &rowList->values, OBJ_VAL(string));
                    pop(vm);
                    break;
                }

If I temporarily halt the GC while .execute happens the segfault also does not appear

Expected Behavior

No response

Steps To Reproduce

No response

Anything else?

No response

Jason2605 commented 1 year ago

Interestingly this may actually be related to the internal Table data structure which would be quite drastic. Reverting the robin hood scheme to the original crafting interpreters scheme seems to resolve the issue (this would also mean dictionaries are broken too as it's the same logic)