This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Bug in dlopen() (or following) code in Cygwin1.dll v 1.5.19-4


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]