[Issue 14692] SIGSEGV during SHA.put

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 23 04:18:57 UTC 2022


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

Mathias LANG <pro.mathias.lang at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |pro.mathias.lang at gmail.com
         Resolution|---                         |INVALID

--- Comment #8 from Mathias LANG <pro.mathias.lang at gmail.com> ---
Looking into this, I noticed the code is triggered from a module constructor:
> #14 0x00000000007687f5 in db.mysql_test() () at source/db.d:17
> #15 0x00000000006f525e in app._sharedStaticCtor1() () at source/app.d:16
> #16 0x0000000000768799 in app.__modsharedctor() ()

The report doesn't mention what version of DMD is being used, but according to
the time of the report, I assume circa 2.068, in which case the line
segfaulting would be
https://github.com/dlang/phobos/blob/v2.068.0/std/digest/sha.d#L723
The stack trace seems to match, and since SHA doesn't change much, I'm pretty
confident this is correct.

The jump to 0x00[...]00 seems to indicate that `transform` is `null`.
Looking into the module, there is indeed a case where it could be `null`: If
`digestSize == 160`, `version = USE_SSSE3`, and the module constructor of your
application was to run before SHA's module ctor
(https://github.com/dlang/phobos/blob/v2.068.0/std/digest/sha.d#L216-L231).

`version = SSSE3` is true on amd64
(https://github.com/dlang/phobos/blob/b82986e64fbb2950af118f4711e1558a4134c803/std/digest/sha.d#L118-L121),
and the first line indicates that `digestSize == 160`:
> #1  0x0000000000712eea in std.digest.sha.SHA!(512, 160).SHA.put(scope const(ubyte)[]...) (this=0x7fffffffd160, input=...) at /usr/include/dmd/phobos/std/digest/sha.d:723

Based on this, I am going to assume the missing piece (order of module ctor) is
indeed the issue. It would also explain why a different version of the
compiler/runtime and a different backend would work (different order of ctor
running).

Hence, the best way forward to fix this issue is to move your code to the
`main`, so that all modules ctor have a chance to run.

--


More information about the Digitalmars-d-bugs mailing list