Win64, merge-2.067, LLVM master, VS 2015 - current status

Dan Olson via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Thu May 14 00:51:19 PDT 2015


"kinke" <noone at nowhere.com> writes:

> On Wednesday, 13 May 2015 at 05:14:57 UTC, Dan Olson wrote:
>>> Apparently an access violation in fiber_switchContext().
>>>
>>> asm:
>>> push rbx
>>> xor  rax,rax
>>> push qword ptr gs:[rax]
>>> push qword ptr gs:[rax+8]
>>> push qword ptr gs:[rax+10h]
>>> mov  qword ptr [rcx],rsp
>>> mov  rsp,rdx
>>> pop  qword ptr gs:[rax+10h] --> access violation with rax=0
>>> pop  qword ptr gs:[rax+8]
>>> pop  qword ptr gs:[rax]
>>> pop  rbx
>>
>> I wonder if it issue #666 [1]?  It looks like the same failure I see
>> on OS X/iOS and only in release builds.  Can you see if it happens
>> in the runShared test?  If so, it may pass if you enable the
>> version(Posix) code for sm_this that uses pthread_get/setspecific
>> [2].
>>
>> [1] https://github.com/ldc-developers/ldc/issues/666
>> [2]
>> https://github.com/ldc-developers/druntime/blob/ldc/src/core/thread.d#L1135
>
> Thx - it crashes during the runShared test. pthread isn't supported on
> Windows. The access violation occurs in
> https://github.com/ldc-developers/druntime/blob/ldc/src/core/thread.d#L3597.

It does seem to be the same problem because the stack to resume on is
wrong.  That is what I see on OS X and iOS.  You could try Windows
TlsGetValue API for sm_this and mimic the pthread_getspecific code.

If it works, I don't think it is a real fix but does allow rest of
thread unittest to run.  Maybe just disabling the runShared test and
documenting is best.

I found this older page where boost decided coroutine migration between
threads was unsafe because of TLS:

http://www.crystalclearsoftware.com/soc/coroutine/coroutine/coroutine_thread.html

Thinking out loud: If LDC could provide a switch to disable TLS address
caching, would folks think to use it?  Should it be on by default to
support the ability to migrate Fibers across threads?  Is it worth the
performance loss in other TLS cases?  Maybe it is better to have some
targets w/ expensive TLS lookup just disable Fiber migration.  Is FIber
migration that common?


More information about the digitalmars-d-ldc mailing list