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
We like to pretend that stt is like Dv during extraction; but it is not: stt has extra preconditions that need to be satisfied. And just because an stt term is fully applied does not mean that these preconditions are met.
The file above extracts to ML code which would do a double free:
openPrimsletfree : 'a . 'a Pulse_Lib_Box.box -> unit -> unit =funb -> funv -> Pulse_Lib_Box.free b ()letdouble_free : 'a . 'a Pulse_Lib_Box.box -> unit -> unit =funb ->
funv ->
Pulse_Lib_Core.hide_div ()() (funuu___ -> free b (); free b ())
What's happening here is that during extraction any fully-applied stt function is extracted to a function call--even if it is not inside an bind_stt and even if the preconditions are not satisfied. The only saving grace is that hide_div is not implemented yet so the code above doesn't compile.
The text was updated successfully, but these errors were encountered:
This one successfully compiles to a working double-free:
openPrimsletfree'bv=let uu___ =Pulse_Lib_Box.free b ()intrueletdouble_free : 'a . 'a Pulse_Lib_Box.box -> unit -> unit -> Prims.bool =funb ->
funv -> let f = free' b ()inlet f1 = free' b ()infunuu___ -> f1
Note that this requires the bool return type. It doesn't work with the unit-returning free, which is erased to ().
gebner
changed the title
Extraction potentially ignores preconditions
Extraction ignores preconditions
Sep 18, 2024
Check that Karamel refuses to compile double_free afterwards because it's higher-order (and doesn't accidentally turn it first-order by removing the unused unit arguments).
We like to pretend that
stt
is likeDv
during extraction; but it is not:stt
has extra preconditions that need to be satisfied. And just because anstt
term is fully applied does not mean that these preconditions are met.The file above extracts to ML code which would do a double free:
What's happening here is that during extraction any fully-applied
stt
function is extracted to a function call--even if it is not inside anbind_stt
and even if the preconditions are not satisfied. The only saving grace is thathide_div
is not implemented yet so the code above doesn't compile.The text was updated successfully, but these errors were encountered: