Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 Message-ID: <602EF4562299D711978800065BEECE9A0D2D30CD@cbrml50.ag.gov.au> From: "Bitmead, Chris" To: "'cygwin AT cygwin DOT com'" Subject: Cygwin.dll crash, alloca and custom stack Date: Fri, 12 Aug 2005 17:07:19 +1000 MIME-Version: 1.0 Content-Type: text/plain I'm writing an implemention of a scheme interpreter in C, and as people familiar with that language know, it requires some stack manipulation. Now to test this out I wrote a little program.... #include int main() { char * st1; st1 = (void *)malloc(5000) + 5000; asm("mov %0, %%esp" : : "r" (st1)); fprintf(stderr, "hello\n"); } This program crashes silently and prints nothing under cygwin. However this kind of thing works fine under Linux. Now if I run it under gdb it says 0x610dfbb3 in cygwin1!_alloca () from /usr/bin/cygwin1.dll Which seems to indicate that the problem has something to do with alloca. Q1. Does cygwin and gcc have a real stack based alloca, or is it a fake simulation? Intuitively I assume that this kind of error would be caused by the latter. Q2. Why does this problem occur? My vague guess is that something in the bootstrap code for cygwin calls alloca, and because of the memory layout of stack and heap, creating a heap based stack makes it free it prematurely. Q3. Shouldn't this be fixed in cygwin? While this is an unusual case, it seems reasonable to me that a program should be able to create a new stack if it wants to. Q4. Is there any work around? I'm guessing that if cygwin uses a fake alloca, then a better implementation would fix it, but is there any way to substitute another one without actually rebuilding cygwin.dll (which I am loath to do). ----------------------------------------------------------------- If you have received this transmission in error please notify us immediately by return e-mail and delete all copies. If this e-mail or any attachments have been sent to you in error, that error does not constitute waiver of any confidentiality, privilege or copyright in respect of information in the e-mail or attachments. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/