Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005819OCamlOCaml backend (code generation)public2012-11-10 16:262013-06-14 13:46
Reporterjm 
Assigned Todoligez 
PriorityimmediateSeveritycrashReproducibilityalways
StatusresolvedResolutionfixed 
PlatformallOSallOS Version
Product Version4.00.1 
Target Version4.01.0+devFixed in Version4.00.2+dev 
Summary0005819: ocamlopt generates segfaulting code when using [with] on recursive record with 6+ fields.
Description% ocamlopt -version
3.11.2
3.12.1
4.01.0+dev10-2012-10-16
% uname -m
i686
x86_64
% cat t.ml
type t =
        { self : t
        ; t0 : int
        ; t1 : int
        ; t2 : int
        ; t3 : int
        ; t4 : int
        }
let rec t =
        { self = t
        ; t0 = 42
        ; t1 = 42
        ; t2 = 42
        ; t3 = 42
        ; t4 = 42
        }
let () =
        let rec self = { t with self=self } in
        print_int self.self.t0
% ocamlopt t.ml && ./a.out
Segmentation fault
TagsNo tags attached.
Attached Filespatch file icon 5819-rec-record-with.patch [^] (940 bytes) 2012-11-14 19:46 [Show Content]
patch file icon 5819-rec-record-with-2.patch [^] (2,659 bytes) 2012-12-04 16:26 [Show Content]

- Relationships
related to 0004141closeddoligez Bus error using doubly-linked, circular list with lazy evaluation 

-  Notes
(0008509)
doligez (administrator)
2012-11-13 16:36

Reproduced with 4.00.2+dev1 on Mac OS X.
(0008510)
doligez (administrator)
2012-11-14 16:37

Here is a patch. I'll get it reviewed by some back-end specialist and then I'll apply it.
(0008517)
frisch (developer)
2012-11-16 16:10
edited on: 2012-11-16 16:10

I'm not a back-end specialist, so I cannot really comment on the proposed patch (except that I believe Record_regular should be Types.Record_regular, etc, unless you're already on the record_disambiguation branch!). But while trying to understand the general compilation strategy for recursive bindings, I found the following lines which I don't really understand:

  let rec init_blocks = function
    ...
    | (id, exp, RHS_nonrec) :: rem ->
        Clet (id, Cconst_int 0, init_blocks rem)

Why do we do that, instead of simply calling "init_block rem" in the RHS_nonrec case? At least, this might allow to catch earlier this kind of bugs. Or are there cases where those dummy bindings are actually needed?

(0008560)
doligez (administrator)
2012-12-04 16:49

I have uploaded a better patch (provided by XL). I have committed it in the 4.00 branch, but not in trunk because we still need to decide whether/how to refactor this function to make it common to the byte-code and native back-ends.

Fixed in 4.00 (r 13110), but this PR stays open until we rework the code in the trunk.

I don't have an answer to frisch's question for the moment.
(0009423)
frisch (developer)
2013-06-06 22:54

Even if we keep this open for further cleanup/sharing, I'd suggest to ensure that the patch will be part of the next release. Unless there is something seriously wrong with it?
(0009488)
xleroy (administrator)
2013-06-14 13:46

Patch #2 was propagated to the trunk by one of Damien's big merges (commit r13699) then cloned in the 4.01 branch. So, all is as it should be. Refactoring can wait. I take the liberty of marking this PR as resolved.

- Issue History
Date Modified Username Field Change
2012-11-10 16:26 jm New Issue
2012-11-13 16:36 doligez Note Added: 0008509
2012-11-13 16:36 doligez Status new => confirmed
2012-11-14 16:32 doligez Assigned To => doligez
2012-11-14 16:32 doligez OS Debian GNU/Linux => all
2012-11-14 16:32 doligez OS Version wheezy =>
2012-11-14 16:32 doligez Target Version => 4.00.2+dev
2012-11-14 16:37 doligez Note Added: 0008510
2012-11-14 19:46 doligez File Added: 5819-rec-record-with.patch
2012-11-16 16:10 frisch Note Added: 0008517
2012-11-16 16:10 frisch Note Edited: 0008517 View Revisions
2012-11-20 11:09 doligez Relationship added related to 0004141
2012-12-04 16:26 doligez File Added: 5819-rec-record-with-2.patch
2012-12-04 16:49 doligez Note Added: 0008560
2012-12-04 16:50 doligez Platform amd64 => all
2012-12-04 16:50 doligez Fixed in Version => 4.00.2+dev
2012-12-04 16:50 doligez Target Version 4.00.2+dev => 4.01.0+dev
2013-06-06 22:54 frisch Note Added: 0009423
2013-06-14 13:46 xleroy Note Added: 0009488
2013-06-14 13:46 xleroy Status confirmed => resolved
2013-06-14 13:46 xleroy Resolution open => fixed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker