X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org MIME-Version: 1.0 Date: Wed, 8 Dec 2010 11:55:49 +0000 Message-ID: Subject: Loading a Cygwin based DLL From: James Dickson To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hey, I just posted (apologies if I have the wrong mailing list) to see if anyone could help me with the following problem. I have successfully managed to load a cygwin based DLL through LoadLibrary into a VC++ 10.0 (as an aside I have also tried 8.0 and 9.0 compiler versions) compiled application, ensuring I have 4k of scratch space as per FAQ 6.16 and the example http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/testsuite/cygload/Attic/cyg= load.cc?cvsroot=3Dsrc. However, if I then proceed to call any function internal or exported from the DLL which makes stack allocations through local variables, the application hangs\crashes. I hope the below example is sufficient to demonstrate the problem and no amount of=A0googling=A0seems to=A0yield the answer, that or I haven't found the right combination of search words. VC++ 10.0 client application: int main(int argc, char ** argv) { =A0=A0 =A0// 4k scratch space. =A0=A0 =A0char *stackbase; =A0=A0 =A0__asm =A0=A0 =A0{ =A0=A0 =A0 =A0 =A0mov eax, fs:[4]; =A0=A0 =A0 =A0 =A0mov stackbase, eax; =A0=A0 =A0} =A0=A0 =A0// Load cygwin dll. =A0=A0 =A0HMODULE cygwin_ptr =3D LoadLibrary(L"cygwin1.dll"); =A0=A0 =A0// error checks omitted.... =A0=A0 =A0init_ptr init =3D (init_ptr)GetProcAddress(cygwin_ptr, "cygwin_dl= l_init"); =A0=A0 =A0// error checks omitted.... =A0=A0 =A0init(); =A0=A0 =A0// Load plugin =A0=A0 =A0HMODULE plugin_ptr =3D LoadLibrary(L"plugin.dll"); =A0=A0 =A0// error checks omitted.... =A0=A0 =A0plugin_ptr exp_test =3D (plugin_ptr)GetProcAddress(plugin_ptr, "plugin_example"); =A0=A0 =A0// error checks omitted.... =A0=A0 =A0exp_test(); // This call hangs the application. } Cygwin based DLL: extern "C" __declspec(dllexport) void plugin_example(void) { =A0=A0 std::wstring tmp(L"some string"); =A0// This for some reason causes the application to hang. =A0=A0 std::wcerr << tmp << std::endl; } I have found I can make it work sometimes, but when I start using more stack allocated local variables the hanging=A0reoccurs. Am I missing something simple? I really hope so. Thank you for any help you can give me. -- James Dickson -- 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