Address of data that is static, be it shared or tls or __gshared or immutable on o/s <x>

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 11 18:31:52 PDT 2017


On Monday, 11 September 2017 at 22:38:21 UTC, Walter Bright wrote:
>
> If an address is taken to a TLS object, any relocations and 
> adjustments are made at the time the pointer is generated, not 
> when the pointer is dereferenced.

Could you elaborate on that explanation more? The way I thought 
about it was that no matter where the data is actually stored 
(global, static, tls, heap, etc.), in order to access it by 
pointer it must be mapped into virtual memory (address) space. 
 From that it follows that each thread will have its own "slice" 
of that address space. Thus, if you pass an address into such a 
slice (that happens to be mapped to the TLS of a thread) to other 
threads, you can manipulate the first thread's TLS data (and 
cause the usual data races without proper synchronization, of 
course).


More information about the Digitalmars-d-learn mailing list