qorelanguage / qore

Qore Programming Language
GNU General Public License v2.0
61 stars 10 forks source link

there are copy-on-write bugs in lvalue handling in the = and += operators #88

Closed davidnich closed 8 years ago

davidnich commented 8 years ago

last release of Qore:

qore -ne 'hash h.a = 1; h.b = h; printf("%y\n", h);' 
{a: 1, b: {a: 1}}

current develop branch:

qore -ne 'hash h.a = 1; h.b = h; printf("%y\n", h);' 
{a: 1, b: {ERROR: recursive reference to hash 0x5b237e0}}

also this is causing a crash in DGC

davidnich commented 8 years ago

the assignment operator makes an optional evaluation, if no evaluation is necessary, then the reference count for the assignment was only incremented after the lvalue is identified, therefore the lvalue can be not copied to make a unique value when the reference_count = 1.

this is related to the QoreValue changes and therefore did not affect Qore 0.8.11.1 (hence the invisible label)

davidnich commented 8 years ago

affects also the += operator:

qore -ne 'string str = "a"; h = (str: 1); h.b += h; printf("%y\n", h);'
{a: 1, b: {ERROR: recursive reference to hash 0x7fd5d050cdb0}}