Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007426OCaml~DO NOT USE (was: OCaml general)public2016-12-06 11:062017-03-03 17:41
Reportertempodox 
Assigned To 
PrioritynormalSeverityblockReproducibilityalways
StatusclosedResolutionduplicate 
PlatformUnixOSMac OS XOS Version10.11.6
Product Version4.04.0 
Target VersionFixed in Version 
Summary0007426: "Fatal error: Assignment of a float to a specialised non-float array" in virtual method
DescriptionIn 4.04.0+flambda, the following code produces an error from `ocamlopt`:

<code>
class virtual abstract =
object (_ : 'self)
  method virtual scaleby : float -> 'self
end

class concrete value =
object
  inherit abstract
  val _value : float = value
  method value = _value
  method scaleby fac =
    {< _value = fac *. _value >}
end
</code>

The error message is:
Fatal error: Assignment of a float to a specialised non-float array: (array.unsafe_set[addr]<>
 copy/95 _value/92
 Pmulfloat/103)
Fatal error: exception Misc.Fatal_error
Steps To ReproducePut this code in an `ml` file and pass it to `ocamlopt`:

class virtual abstract =
object (_ : 'self)
  method virtual scaleby : float -> 'self
end

class concrete value =
object
  inherit abstract
  val _value : float = value
  method value = _value
  method scaleby fac =
    {< _value = fac *. _value >}
end
Additional InformationIn 4.03+flambda, or `ocamlc` of 4.04+flambda, the same code compiles without error.
TagsNo tags attached.
Attached Files

- Relationships
has duplicate 0007474resolvedshinwell flambda fails with internal error when objects have mutable fields of type float 
related to 0007434closedshinwell Ocaml 4.04+flambda weird bug 
related to 0007499resolvedshinwell The flambda manual should document "Fatal error: Assignment of a float to a specialised non-float array" 

-  Notes
(0016635)
gasche (developer)
2016-12-06 13:00

To devs: this means that we need to add more object-oriented programs to the testsuite.
(0016817)
omion (reporter)
2016-12-08 08:57

I encountered the same error with a trivial program:
class some_class = object val some_val = 0.0 end

returns with the error:
>> Fatal error: Assignment of a float to a specialised non-float array: (array.unsafe_set[addr]<>
                                                          self/22 some_val/18
                                                          Parraysetu_arg/30)

Tested with 4.04.0 for Windows x64 and Linux armv7. As tempodox states, ocamlc, 4.04.0 without flambda, and 4.03.0 compile fine.
(0016841)
frisch (developer)
2016-12-08 11:37

I wonder if Translclass shouldn't use Psetfield to write instance variables instead of Parraysetu.
(0016861)
shinwell (developer)
2016-12-08 12:42

@frisch: Indeed. Do you know why the block is treated as an array at present? (My knowledge of the object compilation model is lacking.)
(0016862)
frisch (developer)
2016-12-08 12:45

> Do you know why the block is treated as an array at present?

No, I don't know.
(0016945)
garrigue (manager)
2016-12-10 02:35

The block has to be treated as an array, because the offset is only known at runtime (due to the dynamic nature of class inheritance).
Psetfield only takes a constant offset.
My understanding was that it should be fine to assign a (boxed) float to a generic array (but of course not the way round).
Or do we need a new kind of non-specialized array for this?
Or just an indirect version of Psetfield?
(0016956)
shinwell (developer)
2016-12-12 10:54

I think I know what's going on here now, I will write a patch today.
(0016957)
shinwell (developer)
2016-12-12 11:57

Superceded by https://github.com/ocaml/ocaml/pull/965 [^]

- Issue History
Date Modified Username Field Change
2016-12-06 11:06 tempodox New Issue
2016-12-06 13:00 gasche Note Added: 0016635
2016-12-07 18:17 shinwell Assigned To => shinwell
2016-12-07 18:17 shinwell Status new => assigned
2016-12-08 08:57 omion Note Added: 0016817
2016-12-08 11:37 frisch Note Added: 0016841
2016-12-08 12:42 shinwell Note Added: 0016861
2016-12-08 12:45 frisch Note Added: 0016862
2016-12-10 02:35 garrigue Note Added: 0016945
2016-12-12 10:54 shinwell Note Added: 0016956
2016-12-12 11:57 shinwell Note Added: 0016957
2016-12-12 11:57 shinwell Status assigned => closed
2016-12-12 11:57 shinwell Assigned To shinwell =>
2016-12-12 11:57 shinwell Resolution open => duplicate
2016-12-16 14:03 yallop Relationship added related to 0007434
2017-02-01 12:34 frisch Relationship added has duplicate 0007474
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:41 gasche Relationship added related to 0007499
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker