static vs. shared linking

David Stacey drstacey@tiscali.co.uk
Wed Mar 25 22:42:00 GMT 2015


On 25/03/2015 16:59, Warren Young wrote:
> On Mar 25, 2015, at 3:04 AM, Corinna Vinschen<corinna-cygwin@cygwin.com>  wrote:
>>
>> And this is where it comes from.  It's a call to
>>
>>     void basic_string<_CharT, _Traits, _Alloc>::reserve(size_type __res)
> David, what happens if you say
>
>      wtext.reserve(1);
>
> inside runTests() before the call to crash()?
>
> If that makes the symptom disappear, I wonder if there’s some problem with a Cygwin *.exe owning a std::string that gets resized by a Cygwin *.dll.  If so, that probably*is*  a memory ownership coordination problem that affects Cygwin proper.

Thank you for taking the time to look at this. You are quite correct. 
When I reserve() space on the string in runTests() then the problem goes 
away.

In order to test your hypothesis about memory ownership, I'll create a 
test that malloc(3)s some memory in the .exe and free(3)s it in a shared 
library; Corinna showed that the crash was coming from an abort() in 
free(). However, I can't believe it's that simple - you'd think there 
would be dozens of programmes crashing for this reason.

> I’ve run both versions under valgrind on a Linux box here, and they can find no fault with your code.

Thanks. Obviously, when coming across problems like this, my first 
thought is that I've managed to do something silly. But if neither you, 
me nor Corinna can spot an obvious blunder then that opens the 
possibility that there's something fruity going on.

> On manual inspection, I, too find it to be perfectly cromulent.

Personally, I was thoroughly discombobulated.

Dave.



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list