I got an error when I ran it with the profile flag on Windows.
app.d:
```d
/+ dub.sdl:
dependency "mir-algorithm" version="~>3.10.60"
+/
module app;
import std.stdio;
import mir.ndslice;
void main()
{
auto s = iota(2, 3, 4);
writeln(s);
}
```
run:
```
dub run --build=profile --single app.d
```
result:
```
Program exited with code -1073741819
```
Comment #1 by razvan.nitu1305 — 2021-06-14T16:44:16Z
Have you tried running the program without dub, just to make sure this is not a dub failure?
Comment #2 by lempiji — 2021-06-18T17:02:44Z
The same thing happened when I ran app.exe as is.
I couldn't figure out how to build without using dub.
The link between mir-algorithm.lib and mir-core.lib seems to be necessary, and the condition of occurrence is very difficult to understand.
Also, I replaced 'iota' with 'sliced' and got the same result.
The log for `dub run -v --single --build=profile app.d` looks like this.
Some of the logs are in Japanese.
```
PS C:\work\dev\D\sandbox-mir> dub run -v --single --build=profile app.d
Using dub registry url 'https://code.dlang.org/'
Refreshing local packages (refresh existing: true)...
Looking for local package map at C:\ProgramData\dub\packages\local-packages.json
Looking for local package map at C:\Users\User\AppData\Local\dub\packages\local-packages.json
Try to load local package map at C:\Users\User\AppData\Local\dub\packages\local-packages.json
Determined package version using GIT: my-skelton 0.0.2
Determined package version using GIT: lib-blas 1.0.0
Determined package version using GIT: lib-lapack 1.0.0
Note: Failed to determine version of package finance at .. Assuming ~master.
Determined package version using GIT: test-skelton 1.0.0
Determined package version using GIT: dagon 0.10.1+commit.145.g2f43d56
Determined package version using GIT: tfd 0.0.5+commit.2.g033292d
Determined package version using GIT: libfuture ~master
Determined package version using GIT: golem 0.7.0+commit.2.gf0e91a7
Note: Failed to determine version of package golemancer at .. Assuming ~master.
Determined package version using GIT: lightbulb ~master
Looking for local package map at C:\work\dev\D\sandbox-mir\.dub\packages\local-packages.json
Determined package version using GIT: botan 1.12.19
Determined package version using GIT: botan-math 1.0.3+commit.4.g1b85c88
Determined package version using GIT: memutils 1.0.4+commit.2.g6701e32
Note: Failed to determine version of package sandbox-mir at .. Assuming ~master.
Refreshing local packages (refresh existing: false)...
Looking for local package map at C:\ProgramData\dub\packages\local-packages.json
Looking for local package map at C:\Users\User\AppData\Local\dub\packages\local-packages.json
Try to load local package map at C:\Users\User\AppData\Local\dub\packages\local-packages.json
Determined package version using GIT: my-skelton 0.0.2
Determined package version using GIT: lib-blas 1.0.0
Determined package version using GIT: lib-lapack 1.0.0
Note: Failed to determine version of package finance at .. Assuming ~master.
Determined package version using GIT: test-skelton 1.0.0
Determined package version using GIT: dagon 0.10.1+commit.145.g2f43d56
Determined package version using GIT: tfd 0.0.5+commit.2.g033292d
Determined package version using GIT: libfuture ~master
Determined package version using GIT: golem 0.7.0+commit.2.gf0e91a7
Note: Failed to determine version of package golemancer at .. Assuming ~master.
Determined package version using GIT: lightbulb ~master
Looking for local package map at C:\work\dev\D\sandbox-mir\.dub\packages\local-packages.json
Found dependency mir-algorithm 3.10.60
Found dependency mir-core 1.1.70
Refreshing local packages (refresh existing: false)...
Looking for local package map at C:\ProgramData\dub\packages\local-packages.json
Looking for local package map at C:\Users\User\AppData\Local\dub\packages\local-packages.json
Try to load local package map at C:\Users\User\AppData\Local\dub\packages\local-packages.json
Determined package version using GIT: my-skelton 0.0.2
Determined package version using GIT: lib-blas 1.0.0
Determined package version using GIT: lib-lapack 1.0.0
Note: Failed to determine version of package finance at .. Assuming ~master.
Determined package version using GIT: test-skelton 1.0.0
Determined package version using GIT: dagon 0.10.1+commit.145.g2f43d56
Determined package version using GIT: tfd 0.0.5+commit.2.g033292d
Determined package version using GIT: libfuture ~master
Determined package version using GIT: golem 0.7.0+commit.2.gf0e91a7
Note: Failed to determine version of package golemancer at .. Assuming ~master.
Determined package version using GIT: lightbulb ~master
Looking for local package map at C:\work\dev\D\sandbox-mir\.dub\packages\local-packages.json
Found dependency mir-algorithm 3.10.60
Found dependency mir-core 1.1.70
Generating using build
Configuring dependent app, deps:"mir-algorithm"
Configuring dependent mir-algorithm, deps:"mir-core"
Configuring dependent mir-core, deps:
Performing "profile" build using C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
mir-core 1.1.70: target for configuration "library" is up to date.
Using existing build in C:\Users\User\AppData\Local\dub\packages\mir-core-1.1.70\mir-core\.dub\build\library-profile-windows-x86_64-dmd_v2.097.0-dirty-D627CE87F82063401DAD5E4C3043F56C\.
Copying target from C:\Users\User\AppData\Local\dub\packages\mir-core-1.1.70\mir-core\.dub\build\library-profile-windows-x86_64-dmd_v2.097.0-dirty-D627CE87F82063401DAD5E4C3043F56C\mir-core.lib to C:\Users\User\AppData\Local\dub\packages\mir-core-1.1.70\mir-core
mir-algorithm 3.10.60: target for configuration "default" is up to date.
Using existing build in C:\Users\User\AppData\Local\dub\packages\mir-algorithm-3.10.60\mir-algorithm\.dub\build\default-profile-windows-x86_64-dmd_v2.097.0-dirty-687726DACCEA92C05C74272DCD97EAC4\.
Copying target from C:\Users\User\AppData\Local\dub\packages\mir-algorithm-3.10.60\mir-algorithm\.dub\build\default-profile-windows-x86_64-dmd_v2.097.0-dirty-687726DACCEA92C05C74272DCD97EAC4\mir-algorithm.lib to C:\Users\User\AppData\Local\dub\packages\mir-algorithm-3.10.60\mir-algorithm
File '.' modified, need rebuild.
app ~master: building configuration "application"...
C:\D\dmd2\windows\bin64\dmd.exe -m64 -c -of.dub\build\application-profile-windows-x86_64-dmd_v2.097.0-dirty-65C579894C2BC0DD48D19A35BCFC5075\app.obj -g -inline -O -profile -w -version=Have_app -version=Have_mir_algorithm -version=Have_mir_core -IC:\Users\User\AppData\Local\dub\packages\mir-algorithm-3.10.60\mir-algorithm\source -IC:\Users\User\AppData\Local\dub\packages\mir-core-1.1.70\mir-core\source app.d -vcolumns
Linking...
C:\D\dmd2\windows\bin64\dmd.exe -of.dub\build\application-profile-windows-x86_64-dmd_v2.097.0-dirty-65C579894C2BC0DD48D19A35BCFC5075\app.exe .dub\build\application-profile-windows-x86_64-dmd_v2.097.0-dirty-65C579894C2BC0DD48D19A35BCFC5075\app.obj C:\Users\User\AppData\Local\dub\packages\mir-algorithm-3.10.60\mir-algorithm\.dub\build\default-profile-windows-x86_64-dmd_v2.097.0-dirty-687726DACCEA92C05C74272DCD97EAC4\mir-algorithm.lib C:\Users\User\AppData\Local\dub\packages\mir-core-1.1.70\mir-core\.dub\build\library-profile-windows-x86_64-dmd_v2.097.0-dirty-D627CE87F82063401DAD5E4C3043F56C\mir-core.lib -m64 -g
LINK : 前回のインクリメンタル リンクで .dub\build\application-profile-windows-x86_64-dmd_v2.097.0-dirty-65C579894C2BC0DD48D19A35BCFC5075\app.exe が見つからなかったか、ビル
ドされませんでした。フル リンクを行います。
Copying target from C:\work\dev\D\sandbox-mir\.dub\build\application-profile-windows-x86_64-dmd_v2.097.0-dirty-65C579894C2BC0DD48D19A35BCFC5075\app.exe to C:\work\dev\D\sandbox-mir
To force a rebuild of up-to-date targets, run again with --force.
Running app.exe
Program exited with code -1073741819
```
Comment #3 by lempiji — 2021-06-18T17:12:17Z
By the way, when I rewrote the sample code, I was able to reproduce this as well.
- If delete the dependency in dub.sdl, it won't reproduced.
- If delete import std.stdio and writeln, it won't reproduced.
- If delete &arr[0]; in getptr, it won't reproduced.
```
/+ dub.sdl:
dependency "mir-algorithm" version="*"
+/
import std.stdio;
void main()
{
writeln(getptr(new byte[10]));
}
byte* getptr(byte[] arr)
{
return &arr[0];
}
```
I doubt this is beacause using synchronized (via trace_init) before calling rt_init.
Comment #6 by lempiji — 2021-06-19T15:59:30Z
I was able to minimize the reproducing code, dub was not involved.
app.d:
```
import std.stdio;
void main()
{
auto arr = new byte[10];
writeln(arr);
}
```
test.d:
```
module test;
struct Test {
string msg;
}
```
build&run:
```
dmd.exe -lib -of"test.lib" -profile test.d
dmd.exe -c -of"app.obj" -profile app.d
dmd.exe -of"app.exe" app.obj test.lib
app.exe
```
Comment #7 by me — 2022-06-28T08:35:49Z
I have encountered this with DMD 2.100.0. It seems to be caused by passing pointers/slices to `std.format`:
```
void main()
{
import std.format;
string x = "%s".format(null);
}
```
Run with `dmd -profile -run file.d`. Other flags seem to have no effect.
Comment #8 by me — 2022-06-28T08:51:16Z
Further investigation suggests `__equals` may be to blame:
```
int main()
{
import std.random; // to defeat constant folding
auto a = new int[4];
foreach(ref v; a) v = uniform(0, 10);
auto b = new int[4];
foreach(ref v; b) v = uniform(0, 10);
return cast(int)(a == b);
}
```
This is further supported by debugging a faulty binary, with the debugger stopping on the first overload of __equals: https://github.com/dlang/druntime/blob/cf3f7fe/src/core/internal/array/equality.d#L20-L48
Comment #9 by robert.schadek — 2024-12-13T19:17:01Z