mmap SIGSEGV when memory map is to a class member and modified outside the class
<p>I have a very simple class that opens a file and creates a memory mapped file.</p>

<p>The region is mapped to the member variable called data_ which is defined as unsigned char* data_;</p>

<p>The memory map part looks like this:</p>

<pre><code>// Create memory mapped file
unsigned char* data_ = (unsigned char*)mmap(NULL, 1024, 
                           PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0);

if (block_data_ == MAP_FAILED) {
    throw Exception(std::string("mmap: ") + strerror(errno));
}
</code></pre>

<p>Now I can read and write to the file by simply writing to the data_ variable (up to the size 1024.</p>

<p>But, the intention is not to do it this way.  I have a function that returns me a pointer to data_.<br>
When I simply create the block it works fine all the way up until I try to write to the data OUTSIDE of the class. That's when I get a SIGSEGV.</p>

<p>How do I get around that?</p>
