Thread overview
[Issue 23102] pinholeopt, "Conditional jump or move depends on uninitialised value(s)"
May 11
Basile-z
May 11
Basile-z
May 11
Basile-z
May 12
Basile-z
May 12
Dennis
May 12
Basile-z
May 18
Dlang Bot
May 18
Dlang Bot
May 11
https://issues.dlang.org/show_bug.cgi?id=23102

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |backend, wrong-code

--
May 11
https://issues.dlang.org/show_bug.cgi?id=23102

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
I can find plenty of other repro, e.g

```
module runnable;

import std.random : uniform;

void main(string[] args)
{
    uniform(2000, 5000);
}
```

exposes the same memory error.

--
May 11
https://issues.dlang.org/show_bug.cgi?id=23102

--- Comment #2 from Basile-z <b2.temp@gmx.com> ---
bt for dmd-debug:

---
Conditional jump or move depends on uninitialised value(s)
==1183775==    at 0x8EE36E: pinholeopt(code*, block*) (cod3.d:5761)
==1183775==    by 0x8B987F: codgen(Symbol*) (cgcod.d:435)
==1183775==    by 0x86CD0E: writefunc2(Symbol*) (out.d:1479)
==1183775==    by 0x86C5E6: writefunc(Symbol*) (out.d:1137)
==1183775==    by 0x80EB01: FuncDeclaration_toObjFile(FuncDeclaration*, bool)
(glue.d:1185)
==1183775==    by 0x826EA9: toObjFile::ToObjFile::visit(FuncDeclaration*)
(toobj.d:315)
==1183775==    by 0x733F45: FuncDeclaration::accept(Visitor*) (func.d:2882)
==1183775==    by 0x828045:
_D3dmd5toobj9toObjFileRCQw7dsymbol7DsymbolbZ9ToObjFile5visitMRCQCj9dtemplate16TemplateInstanceZ__T9__lambda2TQDiZQpMFQDqZv
(toobj.d:838)
==1183775==    by 0x6AECEF:
_D3dmd7dsymbol14foreachDsymbolFPSQBf4root5array__T5ArrayTCQCeQCd7DsymbolZQxMDFQvZvZv
(dsymbol.d:105)
==1183775==    by 0x82801E: toObjFile::ToObjFile::visit(TemplateInstance*)
(toobj.d:838)
==1183775==    by 0x6DCA55: TemplateInstance::accept(Visitor*)
(dtemplate.d:7504)
==1183775==    by 0x826E10: toObjFile(Dsymbol*, bool) (toobj.d:1019)
---

--
May 11
https://issues.dlang.org/show_bug.cgi?id=23102

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--
May 12
https://issues.dlang.org/show_bug.cgi?id=23102

--- Comment #3 from Basile-z <b2.temp@gmx.com> ---
the line indicated by the debuginfos does not give variables that are void-initialized. I suspect that the real problem comes from bootstraping. The backend would generate bad code for itself at this specific place.

--
May 12
https://issues.dlang.org/show_bug.cgi?id=23102

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel@live.nl

--- Comment #4 from Dennis <dkorpel@live.nl> ---
(In reply to Basile-z from comment #3)
> the line indicated by the debuginfos does not give variables that are void-initialized. I suspect that the real problem comes from bootstraping. The backend would generate bad code for itself at this specific place.

What host compiler are you using?

Also, can you reproduce this without Phobos imports?

--
May 12
https://issues.dlang.org/show_bug.cgi?id=23102

--- Comment #5 from Basile-z <b2.temp@gmx.com> ---
host compiler : v2.098.0

I have not tried to reproduce without Phobos for now.

--
May 18
https://issues.dlang.org/show_bug.cgi?id=23102

duser@neet.fi changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |duser@neet.fi

--- Comment #6 from duser@neet.fi ---
Created attachment 1852
  --> https://issues.dlang.org/attachment.cgi?id=1852&action=edit
fix

minimal reproducer

uint fn(uint a)
{
        return 1 / a;
}

compile: valgrind dmd -O -c test.d

with "--track-origins=yes", valgrind also prints what function the uninitialized data comes from

==17569==  Uninitialised value was created by a stack allocation
==17569==    at 0x70AADF: cddiv(CodeBuilder&, elem*, unsigned int*)
(cod2.d:1298)

there was a void-initialized struct there, the patch fixes this by initializing the field that was checked at "cod3.d:5761" in the backtrace

--
May 18
https://issues.dlang.org/show_bug.cgi?id=23102

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dmd pull request #14139 "Fix issue 23102 - pinholeopt, "Conditional jump or move depends on un…" fixing this issue:

- Fix issue 23102 - pinholeopt, "Conditional jump or move depends on
uninitialised value(s)"

https://github.com/dlang/dmd/pull/14139

--
May 18
https://issues.dlang.org/show_bug.cgi?id=23102

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14139 "Fix issue 23102 - pinholeopt, "Conditional jump or move depends on un…" was merged into stable:

- 51e9e039b204bcd7221d41d37f1ad657bf05c8e7 by Dennis Korpel:
  Fix issue 23102 - pinholeopt, "Conditional jump or move depends on
uninitialised value(s)"

https://github.com/dlang/dmd/pull/14139

--