delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/03/09/11:28:15

X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: Bug in dlopen() (or following) code in Cygwin1.dll v 1.5.19-4
Date: Thu, 9 Mar 2006 16:27:56 -0000
Message-ID: <072a01c64396$6c3a18e0$a501a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
In-Reply-To: <20060309155635.72549.qmail@web53014.mail.yahoo.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 09 March 2006 15:57, Gary Zablackis wrote:

> Here is a simplified test to show what is going on:

  A few comments.  First off, attachments are good for testcases.
Line-wrapping is bad for them!  Secondly, you omitted Crash2.h, and thirdly,
you had an inconsistency - you listed a file as OK.c but the shell script
builds OK.cc.

> ------Simple script to put everything together:
> #!/bin/sh
> #NOTE: add -DHARDLINKTEST to ct.c compile to get
> #      a non-crashing exe
> #1st dll to be dlopen()ed only:
> gcc -DDEBUG -gstabs+ -g3 -fno-strict-aliasing -Wall -c
> CrashTest.cc -o CrashTest.o

  This is, strictly-speaking, wrong.  Don't use gcc to compile C++, use g++
instead.

  Anway, I created a blank Crash2.h and renamed OK.c to OK.cc and changed the
invocations of gcc to invoke g++ and I compiled everything and got the crash.
Then I added "-W -Wall" to the compile line for ct.c and saw...

ct.c: In function `main':
ct.c:11: warning: unused variable `ret'
ct.c: At top level:
ct.c:9: warning: unused parameter 'argc'
ct.c:9: warning: unused parameter 'argv'
ct.c: In function `main':
ct.c:22: warning: control reaches end of non-void function
ct.c: In function `TestLoad':
ct.c:42: warning: implicit declaration of function `dlopen'
ct.c:51: warning: int format, DWORD arg (arg 2)
ct.c:58: warning: unused variable `uReturnVal'
ct.c:63: warning: int format, DWORD arg (arg 2)

so I added #include <dlfcn.h> and got 

ct.c: In function `main':
ct.c:13: warning: unused variable `ret'
ct.c: At top level:
ct.c:11: warning: unused parameter 'argc'
ct.c:11: warning: unused parameter 'argv'
ct.c: In function `main':
ct.c:24: warning: control reaches end of non-void function
ct.c: In function `TestLoad':
ct.c:44: error: too few arguments to function `dlopen'
ct.c:53: warning: int format, DWORD arg (arg 2)
ct.c:60: warning: unused variable `uReturnVal'
ct.c:65: warning: int format, DWORD arg (arg 2)

  So, your code is not correct.  I'm also confused why you use dlopen to open
the file, but then you go and use the win32 GetProcAddress instead of the
POSIX function dlsym when you want to look up the address.  I don't know if
arbitrarily mixing POSIX and win32-isms like that is even supposed to work.

  At this point I'm stopping.  If you post a fixed testcase, I'll take a look
at it.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019