Array ops give sharing violation under Windows 7 64 bit?

Don nospam at nospam.com
Sun Mar 25 00:07:57 PDT 2012


On 24.03.2012 19:55, Walter Bright wrote:
> 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?
>

Bug 6660. I don't understand it, but the minimal test case is very 
simple, just a few asm instructions, no function calls.
As I reported there, all that is required is a use of CPUID 2 or 4. Any 
use of CPUID 1 or 3 doesn't trigger the bug.
It seems to me as though somehow, one processor is being kept alive 
after the process has ended.
I wasn't sure if this was an OS issue or a processor issue. But if 
you're seeing this after upgrading an individual machine, it definitely 
has to be a Windows 7 bug. I'm relieved to hear that someone else can 
reproduce it.



More information about the Digitalmars-d mailing list