static vs. shared linking
David Stacey
drstacey@tiscali.co.uk
Wed Mar 25 23:28:00 GMT 2015
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
More information about the Cygwin
mailing list