Bug 12699 – Possibly wrong code in object_.d

Status
NEW
Severity
normal
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-04T12:33:51Z
Last change time
2024-12-07T13:33:46Z
Assigned to
No Owner
Creator
Andrej Mitrovic
Moved to GitHub: dmd#17275 →

Comments

Comment #0 by andrej.mitrovich — 2014-05-04T12:33:51Z
TypeInfo_AssociativeArray is a TypeInfo class and its 'getHash' method is implemented as: override hash_t getHash(in void* p) nothrow @trusted const { return _aaGetHash(cast(void*)p, this); } But _aaGetHash expects an 'AA* aa' as the first parameter, not a TypeInfo. As a result _aaGetHash will sometimes crash while attempting to access 'aa.impl.buckets', since at that offset it's accessing whatever happens to lay at that address in a TypeInfo class. This change was introduced in commit 87e5f64. Unless I'm misunderstanding something I don't think the above is right.
Comment #1 by dfj1esp02 — 2014-05-30T10:50:46Z
AA* should be passed as an argument for getHash(void*), it's used for computing hash of object of the type with which this TypeInfo is associated.
Comment #2 by code — 2016-06-18T00:22:57Z
Somewhat related to issue 12516 in that the API shouldn't be @trusted in the first place.
Comment #3 by robert.schadek — 2024-12-07T13:33:46Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17275 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB