You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following example program seems to illustrate a bug when starting with an empty varray:
openVarraylet t = empty ( )
push_back t '.'
pop_front t
Interestingly, the behaviour seems to depend on the particular platform this is running on. On my MacBook with M2 ARM the above program results in a segmentation fault. On my Intel MacBook it returns a character, however, it is not the one previously pushed and it also changes each time the program is run.
FWIW I get an assertion failure in utop, it looks like t.length is 0 in pop_front in circular.ml. Apparently push_back_new never updates t.first. push_front works.
Are you running with assertions off when you get the segfault?
This fixes the assertion failure, but I don't know enough about how varray works to know whether this change is correct or whether it'd need to also be done in other places (if you found this using property testing, then property testing could probably be used to find internal invariant failures like this):
diff --git a/src/root.ml b/src/root.ml
index 8fef9be..b2bb377 100644
--- a/src/root.ml+++ b/src/root.ml@@ -100,6 +100,7 @@ module Make (V : Varray_sig.TIER)
let create_child ~lc t i x =
let row = V.make ~lc 1 x in
+ if i = 0 then t.first <- row;
Buffer.set ~lc t.rows i row
let initialize ~lc t =
It looks like the dune file in varray turns off assertions in release mode (which seems like a bad idea when running tests!).
The following example program seems to illustrate a bug when starting with an empty varray:
Interestingly, the behaviour seems to depend on the particular platform this is running on. On my MacBook with M2 ARM the above program results in a segmentation fault. On my Intel MacBook it returns a character, however, it is not the one previously pushed and it also changes each time the program is run.
This was found with an upcoming feature in ortac/qcheck-stm
The text was updated successfully, but these errors were encountered: