REBOL3 tracker
  0.9.12 beta
Ticket #0000802 User: anonymous

Project:



Short URL: http://issue.cc/r3/802
rss
TypeBug Statustested Date12-May-2009 23:06
Versionalpha 66 CategoryUnspecified Submitted byKulero
PlatformWindows Severitymajor Priorityhigh

Summary make object crashes if a field is assigned self, but not reassigned in the spec
Description Version 2.100.53.3.1
I was experimenting with creating new "types" as prototypes, with overriding, and with argument restriction.

I'll make each line complete since console doesn't do line continuation.
Example code
; Boiled down version:
a: make object [b: self] []  ; [sic]


;First do
warrior!: make object! [proto: self attack: func [target][print ["Attacked" target]]]
;Interestingly, this works fine
rifleman!: make warrior! [proto: self range: 200 attack: func [target][print ["Shot" target]]]
;But this CRASHES
warrior-dave: make warrior! []

Assigned ton/a Fixed inalpha 80 Last Update3-Sep-2009 06:35


Comments
(0000702)
BrianH
13-May-2009 02:47

Tested and confirmed, subject changed accordingly. The crash makes the process go away with no system error or even Windows crash dialog. Can someone test other platforms?
(0000857)
Carl
27-May-2009 22:06

Bug is caused by deep copy recursion.
(0000943)
maxim
13-Jun-2009 21:24

note: this also happens with a sub-object linking to parent object...

which is a major concern, since MANY object setups use bi-directional object references.

I'm just pointing this out to make it obvious that its a bigger problem than the unusual case where one object points to itself.
(0000944)
maxim
14-Jun-2009 01:27

After getting my composure back from realizing that make object! does a deep copy of objects within objects, I feel I must point out how much that decision will hurt REBOL. (sorry for the long post)

This decision is so fundamental that it deserves to be addressed differently. There is need for deep copying objects, I can see some places where this would be useful, but there are also times when this is very evil.

Data sharing is an integral part of a well designed system. what you propose feels like dumbing down REBOL.

Try asking a C programmer that he will never be able to copy just the pointers to structures within structure... and he will either become insane or start a murderous rampage... what you are proposing here is exactly that.

Note, this is not about wanting R3 to be compatible with R2.

When I built liquid I was able to improve speed and total allocation space of nodes by a factor of 100 (that's 100 times better). specifically because R2 doesn't copy objects within objects.

PITL requires very thorough control over this kind of issue and for the interpreter to force us down that path makes no sense. Series copying series in objects is already borderline (though I understand why it was done.)

what really needs to be done is to finally improve make by allowing some of it to be controlled. Either adding a limited number of refinements or creating new functions which allow better control over memory allocation/refering.

/copy /deep and /recursive could be added to make and used in types where it makes sense, including user types, to allow them to be as efficient as can be.

alternatively a standardized init or clone function could be supported within object! which allows FULL control on how internals are treated when a new instance of a prototype is created.
(0001232)
BrianH
5-Jul-2009 00:25

As of alpha 66 this throws a stack overflow error instead of crashing - changed the ticket accordingly.

Date User Field Action Change
3-Sep-2009 06:35 BrianH Fixedin Modified => alpha 80
3-Sep-2009 06:35 BrianH Category Modified => Unspecified
3-Sep-2009 06:35 BrianH Status Modified reviewed => tested
5-Jul-2009 00:25 BrianH Comment : 0001232 Added -
5-Jul-2009 00:24 BrianH Version Modified alpha 53 => alpha 66
5-Jul-2009 00:24 BrianH Severity Modified crash => major
14-Jun-2009 01:27 maxim Comment : 0000944 Added -
13-Jun-2009 21:24 maxim Comment : 0000943 Added -
27-May-2009 22:06 carl Comment : 0000857 Added -
27-May-2009 22:06 carl Summary Modified make object crashes system if a field in the prototype is assigned self, but not reassigned in the spec => make object crashes if a field is assigned self, but not reassigned in the spec
27-May-2009 22:06 carl Code Modified -
13-May-2009 02:48 BrianH Comment : 0000702 Modified -
13-May-2009 02:47 BrianH Comment : 0000702 Added -
13-May-2009 02:46 BrianH Summary Modified make object crashes system => make object crashes system if a field in the prototype is assigned self, but not reassigned in the spec
13-May-2009 02:46 BrianH Description Modified -
13-May-2009 02:46 BrianH Code Modified -
13-May-2009 02:46 BrianH Status Modified submitted => reviewed
13-May-2009 02:46 BrianH Priority Modified normal => high
12-May-2009 23:06 Kulero Ticket Added -