New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CamlinternalLazy not flambda-proof? #7292
Comments
Comment author: @alainfrisch For now, we compile with this local change: Index: inline_and_simplify.ml =================================================================== --- inline_and_simplify.ml (revision 95085) +++ inline_and_simplify.ml (working copy) @@ -1017,6 +1017,7 @@ | (Psetfield _ | Parraysetu _ | Parraysets _), _block::_, block_approx::_ -> if A.is_definitely_immutable block_approx then begin + if dbg.Debuginfo.dinfo_file <> "camlinternalLazy.ml" then (* LEXIFI, see OCaml #7292 *) Location.prerr_warning (Debuginfo.to_location dbg) Warnings.Assignment_to_non_mutable_value end; I don't know if this is safe (i.e. if the "unsafe set_field" in camlinternalLazy cannot break anything), but it is better than disabling that warning globally. (Due to our local "lazy let rec" construction, we end up with a lot of "lazy functions".) |
Comment author: @alainfrisch We get a segfault on a piece of code with flambda -O3; this code uses Lazy and the segfault disappears with simple changes such as (lazy x --> Lazy.from_val x) (where x is an identifier). So I'm wondering if the warning reported in this PR could be related. Could it be that "unsafe" mutations done in camlinternalLazy are really unsafe with flambda -O3? More details: the 'x' refers in fact to a function, but hidden behind an abstract type. So for "lazy x", Translcore produces a forward block (because it doesn't know the definition of the abstract type and if it were "float", it could be compile the expression as "x"). For "Lazy.from_val x", flambda inlines the called function; since it knows that "x" refers to a closure, this removes the tag check in Lazy.from_val, and this produces simply a reference to "x". (Optimization note: Perhaps in flambda mode, Translcore should compile "lazy x" to "Lazy.from_val x" instead of producing the forward block itself, in order to benefit from further optimization. Alternatively flambda should optimize away forward blocks pointing to values of non-float types.) |
Comment author: @alainfrisch Segfaulting program reduced and reported in #7301. |
Comment author: @mshinwell I am looking at this |
Comment author: @mshinwell Please see #713 |
Comment author: @alainfrisch And #714 |
Comment author: @mshinwell Fixed for 4.04 |
Original bug ID: 7292
Reporter: @alainfrisch
Assigned to: @mshinwell
Status: closed (set by @xavierleroy on 2017-09-24T15:33:15Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.04.0 +dev / +beta1 / +beta2
Fixed in version: 4.04.0 +dev / +beta1 / +beta2
Category: back end (clambda to assembly)
Related to: #7301
Monitored by: braibant
Bug description
Compiling the following:
with flambda and O3 prints the following error message 9 times:
(Note that the error message refers to camlinternalLazy.ml while we are compiling another unit.)
The text was updated successfully, but these errors were encountered: