Bug 20892 – [REG2.086] ElfFile comparison suboptimal

Status
NEW
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-01T22:24:26Z
Last change time
2024-12-07T13:40:20Z
Assigned to
No Owner
Creator
johanengelen
Moved to GitHub: dmd#17405 →

Comments

Comment #0 by johanengelen — 2020-06-01T22:24:26Z
The alias_this-->opEquals change ( https://dlang.org/changelog/2.086.0.html#alias_this_opEquals) silently resulted in ElfFile comparison potentially comparing a lot of memory, instead of pointer comparison as before. It concerns core.internal.elf.io.ElfIO.ElfFile, member MMapRegion!Elf_Ehdr ehdr. Snippet: ``` struct MMapRegion(T) alias data this; private ubyte[] mappedRegion; const(T)* data; ``` Before 2.086, only MMapRegion.data would be compared (pointer comparison), but since 2.086 now the whole mappedRegion is compared (potentially). Quick checking of druntime's dynamic array comparison and glibc memcmp showed that there is no short circuit for when the pointers of the slices are equal.
Comment #1 by bugzilla — 2020-06-02T05:38:09Z
Does this mean your specific code can be fixed by adding a MMapRegion.opEquals function? Given that this was merged nearly a year ago, I expect there'd be more silent breakage if it was reverted.
Comment #2 by johanengelen — 2020-06-02T19:43:00Z
("your specific code": don't fully understand, as this is druntime's code :)) https://github.com/dlang/druntime/blob/ebfe05ea945f9ef0eb56b7f3b02a07df2fc64901/src/core/internal/elf/io.d#L287 Yes, I think this instance can be fixed with an explicit TypedMMapRegion.opEquals.
Comment #3 by robert.schadek — 2024-12-07T13:40:20Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17405 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB