This is the mail archive of the cygwin-developers@sources.redhat.com 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]

Re: _impure_ptr uninitialized in DLLs?


This should be fixed in CVS now.  It will require updating libcygwin.a.

cgf

On Tue, Jul 11, 2000 at 06:41:47PM +0100, Fifer, Eric wrote:
>
>>I've checked in a fix for this.  It was pretty tricky.  Let's see if I
>>actually got it right.
>
>_impure_ptr seems to be working fine now.  Thanks.
>
>Unfortunately now, another problem is that environ seems to get clobbered
>by a dlopen(), so getenv() generates a STATUS_ACCESS_VIOLATION
>at environ.cc:152 (my_findenv).
>
>Again, I'll try to hunt down the problem, but I thought I
>should report it in the meantime.
>
>Here's the demonstration of the problem:
>
>d.c:
>
>#include <unistd.h>
>
>int __declspec(dllexport) d()
>{
>    printf("in d\n");
>    printf("environ=%x\n", environ);
>}
>
>m.c:
>
>#include <dlfcn.h>
>#include <unistd.h>
>
>main() {
>    void *libref;
>    int (*symref)();
>
>    printf("environ=%x\n", environ);
>    printf("PATH=%s\n", getenv("PATH"));
>
>    libref = dlopen("libd.dll", RTLD_LAZY);
>    symref = dlsym(libref, "d");
>    symref();
>
>    printf("environ=%x\n", environ);
>    printf("PATH=%s\n", getenv("PATH"));
>}
>
>compile:
>
>gcc -g -c d.c
>dllwrap --output-lib libd.a --dllname libd.dll d.o
>gcc -g -c m.c
>gcc -o m m.o
>
>run:
>
>PATH=/bin:/usr/local/bin:.
>in d
>environ=0
>environ=a040008
>      0 [main] m 1213 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
>  13162 [main] m 1213 stackdump: Dumping stack trace to m.exe.stackdump
>
>prior to Jul-01:
>
>environ=a040008
>PATH=/bin:/usr/local/bin:.
>in d
>environ=a040008
>environ=a040008
>PATH=/bin:/usr/local/bin:.
>
>Thanks,
>
>Eric Fifer

-- 
cgf@cygnus.com                        Cygnus Solutions, a Red Hat company
http://sourceware.cygnus.com/         http://www.redhat.com/

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