Array ops give sharing violation under Windows 7 64 bit?

Nick Sabalausky a at a.a
Sat Mar 24 12:31:03 PDT 2012


"Walter Bright" <newshound2 at digitalmars.com> wrote in message 
news:jkl5ab$1ocp$1 at digitalmars.com...
> I've been upgrading to a Windows 64 bit box. Running the D test suite, I 
> ran into a very strange problem. Here's the program:
>
> ---------------------------
>  extern(C) int printf(const char*, ...);
>
>  int main()
>  {
>      byte[3] a;
>      byte[3] b;
>      byte[3] c;
>
>      a[] = b[] + c[];
>
>      printf("Success\n");
>      return 0;
>  }
> ---------------------------
>
> I run it from a cc.bat file that has the contents:
>
> --------------------------
>  ..\dmd test
>  test
>  ..\dmd test
> --------------------------
>
> and the result is:
> --------------------------
>  C:\test>..\dmd test
>
>  C:\test>test
>  Success
>
>  C:\test>..\dmd test
>  GetLastError = 32 test.exe
>  OPTLINK (R) for Win32  Release 8.00.12
>  Copyright (C) Digital Mars 1989-2010  All rights reserved.
>  http://www.digitalmars.com/ctg/optlink.html
>  OPTLINK : Error 3: Cannot Create File test.exe
>  --- errorlevel 1
> ---------------------------
>
> Note the failure to write out test.exe. I instrumented Optlink to figure 
> out why, and the CreateFile() returns error 32, which is "The process 
> cannot access the file because it is being used by another process."
> If you run the commands by typing them in (not via a .bat file) it works. 
> If the array
> operations are removed, it works. It works on Windows XP.
>
> I'm mystified. Does anyone have any ideas?
>

Windows is known to enjoy holding locks on files just for the fuck of it. 
See if the behavior changes if you add some delay just before the last line. 
Or, if you adjust it so that compiling test.d takes longer.




More information about the Digitalmars-d mailing list