This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: static vs. shared linking
- From: David Stacey <drstacey at tiscali dot co dot uk>
- To: cygwin at cygwin dot com
- Date: Wed, 25 Mar 2015 22:48:33 +0000
- Subject: Re: static vs. shared linking
- Authentication-results: sourceware.org; auth=none
- References: <5510A9AB dot 7020607 at tiscali dot co dot uk> <5511AF73 dot 9070607 at tiscali dot co dot uk> <20150325090453 dot GB3017 at calimero dot vinschen dot de> <850E2E37-EA86-448E-9B9F-206C662E14E5 at etr-usa dot com> <55133295 dot 1090105 at tiscali dot co dot uk>
On 25/03/2015 22:11, David Stacey wrote:
On 25/03/2015 16:59, Warren Young wrote:
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.
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.
Indeed. I created a very simple test that alloc(3)s memory in main() and
then free(3)s it in a shared library. That works fine. So there's more
to it than that :-(
Dave.
// crash_library.h
#ifndef CRASH_LIBRARY_H
#define CRASH_LIBRARY_H
extern void Crash(unsigned short *ptr);
#endif // CRASH_LIBRARY_H
// crash_library.cpp
#include "crash_library.h"
#include <stdlib.h>
void Crash(unsigned short *ptr)
{
free(ptr);
}
// main.cpp
#include "crash_library.h"
#include <stdlib.h>
int main()
{
unsigned short*ptr = (unsigned short*)malloc(sizeof(unsigned short));
Crash(ptr);
return 0;
}
--
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