[Issue 20892] New: [REG2.086] ElfFile comparison suboptimal

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 1 22:24:26 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20892

          Issue ID: 20892
           Summary: [REG2.086] ElfFile comparison suboptimal
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: johanengelen at weka.io

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.

--


More information about the Digitalmars-d-bugs mailing list