<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
I can reproduce the issue on Win7 64, but not on XP. I have debugged
it a little until I noticed that the generated code for TLS access
seems broken:<br>
<br>
dmd 2.054 generated this code for the append operation<br>
<br>
push 1 <br>
1000207D mov ecx,dword ptr [__tls_index (1006BF98h)] <br>
10002083 mov edx,dword ptr fs:[2Ch] <br>
1000208A mov ebx,dword ptr [edx+ecx*4] <br>
1000208D lea esi,[ebx+4] <br>
10002093 push esi <br>
10002094 mov eax,offset TypeInfo_Ai@__init (1005E9A0h) <br>
10002099 push eax <br>
1000209A call __d_arrayappendcT (10004D68h) <br>
<br>
while the beta generates<br>
<br>
push 1 <br>
10002076 mov ecx,dword ptr fs:[2Ch] <br>
1000207D mov edx,dword ptr [ecx] <br>
1000207F lea ebx,[edx+4] <br>
10002085 push ebx <br>
10002086 mov esi,offset TypeInfo_Ai@__init (10067A90h) <br>
1000208B push esi <br>
1000208C call __d_arrayappendcT (10004F9Ch) <br>
<br>
so it completely ignores the tls_index. I guess it works on XP
because there are less DLLs that use TLS, so the DLLs index ends up
as 0.<br>
<br>
Rainer<br>
<br>
PS: one possibly bad thing: printf is imported from the LLVM DLL,
not from the dmc runtime library. This might add more confusion.<br>
<br>
<br>
On 06.09.2011 15:06, Sönke Ludwig wrote:
<blockquote cite="mid:4E661ABB.7060103@informatik.uni-luebeck.de"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
I will try that in a few hours when I'm back from work.<br>
<br>
Am 06.09.2011 08:16, schrieb Walter Bright:
<blockquote cite="mid:4E65BAD8.80900@digitalmars.com" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Could you get the druntime sources for the last dmd release, try
those, and see if it works successfully?<br>
<br>
On 9/5/2011 10:52 PM, Sönke Ludwig wrote:
<blockquote
cite="mid:4E65B527.2010503@informatik.uni-luebeck.de"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Am 05.09.2011 23:53, schrieb Rainer Schuetze:
<blockquote cite="mid:4E6544EC.1080204@gmx.de" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
On 05.09.2011 21:35, Sönke Ludwig wrote:
<blockquote
cite="mid:4E65247F.2090705@informatik.uni-luebeck.de"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Am 05.09.2011 19:54, schrieb Rainer Schuetze:
<blockquote cite="mid:4E650CBA.6080702@gmx.de" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<br>
What OS are you running on? <br>
<br>
Your code works for me (XP SP3). Also Visual D works
fine AFAICT (its a plugin DLL to VS).<br>
<br>
</blockquote>
Windows 7 x64 SP1... But it is more complicated than it
seemed.<br>
<br>
I had another file linked to the DLL that I thought had
not effect. But actually it used a function from another
DLL* that was linked in statically via passing a .lib file
to the command line (along with the source files). The
error does not occur if compiling and linking is done by
separate invocations of dmd. Also commenting out all the
lines that use a function from the external DLL fixes the
problem.<br>
<br>
(* that DLL is LLVM 2.9, so no D code inside)<br>
<br>
<br>
</blockquote>
<br>
There might be issues if you are calling another DLL from
inside the (non-shared) static constructors and that DLL
also uses TLS. In DllMain(DLL_PROCESS_ATTACH), each existing
thread is initialized by just swapping the TLS data of the
DLL and then running the module initialization. So if
another DLL is called, it will only see the TLS of the
thread that called DllMain.<br>
<br>
I don't think anything in this code has changes recently. Is
this a regression from the last dmd version?<br>
<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
dmd-beta mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:dmd-beta@puremagic.com">dmd-beta@puremagic.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.puremagic.com/mailman/listinfo/dmd-beta">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a></pre>
</blockquote>
Yes, it is a regression in the first beta. The new beta also
has it.<br>
<br>
In general, the LLVM DLL was not called at all before the
error occurs, the pure fact that there was a dependency to it
somewhere in the code causes the problem. Also, it doesn't
matter whether the array is used somwhere inside of DllMain or
later from within an exported function (this was actually the
case before I tried to strip it down). There is just one
static constructor in the code. Commenting it out does not
affect the problem.<br>
<br>
I now completely removed any other code and just put in one
function call after the array appending line. Commenting out
the llvm call will cause the array to be correctly
initialized/referenced, otherwise it contains garbage in its
ptr/length fields. (making it __gshared also fixes it)<br>
<br>
The llvm.lib containing the llvm functions was generated from
the dll using implib.<br>
<br>
---<br>
import std.c.windows.windows;<br>
import core.sys.windows.dll;<br>
<br>
import llvm.target;<br>
int[] test;<br>
<br>
extern (Windows)<br>
BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID
pvReserved) <br>
{ <br>
switch (ulReason) {<br>
default: return false;<br>
case DLL_PROCESS_ATTACH:<br>
if( !dll_process_attach( hInstance, true ) )
return false;<br>
test ~= 1; // throws out of memory<br>
LLVMInitializeX86TargetInfo(); // commenting out
this will make it work<br>
break;<br>
case DLL_PROCESS_DETACH: dll_process_detach(
hInstance, true ); break;<br>
case DLL_THREAD_ATTACH: dll_thread_attach( true, true
); break;<br>
case DLL_THREAD_DETACH: dll_thread_detach( true, true
); break;<br>
}<br>
return true;<br>
}<br>
---<br>
<pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
dmd-beta mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:dmd-beta@puremagic.com">dmd-beta@puremagic.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.puremagic.com/mailman/listinfo/dmd-beta">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a></pre>
</blockquote>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
dmd-beta mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:dmd-beta@puremagic.com">dmd-beta@puremagic.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.puremagic.com/mailman/listinfo/dmd-beta">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a></pre>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
dmd-beta mailing list
<a class="moz-txt-link-abbreviated" href="mailto:dmd-beta@puremagic.com">dmd-beta@puremagic.com</a>
<a class="moz-txt-link-freetext" href="http://lists.puremagic.com/mailman/listinfo/dmd-beta">http://lists.puremagic.com/mailman/listinfo/dmd-beta</a></pre>
</blockquote>
<br>
</body>
</html>