This is the mail archive of the cygwin-developers 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: LoadLibrary error 487 (was Re: Please test latest developer snapshot)


On Feb 26 18:30, Christopher Faylor wrote:
> On Sat, Feb 26, 2011 at 10:42:28PM +0100, Corinna Vinschen wrote:
> >On Feb 26 21:26, Corinna Vinschen wrote:
> >> On Feb 26 19:45, Corinna Vinschen wrote:
> >> > On Feb 26 19:43, Corinna Vinschen wrote:
> >> > > On Feb 26 13:23, Christopher Faylor wrote:
> >> > > > The other thing we could do is add a flag to thd dll_info struct which says
> >> > > > "Use DONT_RESOLVE_DLL_REFERENCES" either in the forkee or always depending
> >> > > > on what works for winm.dll.
> >> > > 
> >> > > That's what I meant above.  It would require a new LoadDLLfuncEx4,
> >> > > wouldn't it?  OTOH, LoadDLLfuncEx3 is only referred to via the
> >> > > definition of LoadDLLfuncEx2, so it should be simple to redefine.
> >> > 
> >> > Btw., what is the "fn" argument to LoadDLLfuncEx3 good for?  Given that
> >> > it's always 0 it seems pretty useless right now...
> >> 
> >> Erm... I don't know what fn is supposed to do, but right now it's
> >> value is simply used for the error code.  In LoadDLLprime it's put
> >> into the upper 8 bytes of the decoration:
> >> 
> >>   .long (" #n "+" #notimp ") | (((" #err ") & 0xff) <<16) | (((" #fn ") & 0xff) << 24)
> >> 
> >> And in noload it's simply returned together with the err value:
> >> 
> >>   [...]
> >>   andl    $0xffff0000,%eax# upper word
> >>   [...]
> >>   pushl   %eax            # Save for later
> >>   [...]
> >>   popl    %eax            # Get back argument
> >>   sarl    $16,%eax        # return value in high order word
> >>   jmp     *%edx           # Return
> >> 
> >> My question is, shouldn't there be an additional
> >> 
> >>   andl    $0x000000ff,%eax
> >> 
> >> right before the jmp?  This would also allow to use the fn value
> >> for the purpose discussed above.
> >
> >Here's my final patch, assuming I got that right with LoadDLLfuncEx3 and
> >err and fn.  I'm using the fn parameter to LoadDLLfuncEx3 as an 8 bit
> >flag value now.  std_dll_init checks if the lowest bit is set, and only
> >then it calls LoadLibraryExW.  Is that ok?
> 
> I chose to do things a little differently.  I store the flag value once
> per dll and got rid of the fn field entirely.

Thanks, but your code only works on XP, not on Winodws 7.  In fact,
on Windows 7 Cygwin is now entirly broken since every single fork
segfaults.

dll_load can't just call LoadLibraryExW(DONT_RESOLVE_DLL_REFERENCES) on
winmm just because it's in a forkee.  It has to check if a prior call to
LoadLibrary (or LoadLibraryExW(0) failed with ERROR_INVALID_ADDRESS since
only an OS on which that happens is affected by the problem.  Otherwise,
as I wrote in http://cygwin.com/ml/cygwin-developers/2011-02/msg00012.html,
it's plain wrong to load a DLL with the DONT_RESOLVE_DLL_REFERENCES flag
set, if you need a working copy of that DLL.

I applied a patch which changes dll_load accordingly so I can generate a
new snapshot to let others test ASAP.  I'm still trying to get 1.7.8 out
of the door tomorrow.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


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