This is the mail archive of the cygwin@sourceware.cygnus.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: call_handler, interrupt_now and interruptible



"Ray Easton" writes:
>> Anyways, is this dangerous to do?
>
>If 'this' means interrupting a DLL while it is "paused on a system
>call", yes, it is extermely dangerous and can leave the NT kernel in a
>corrupt state.  (This has nothing to do with Cygwin -- this is purely
>an NT issue.)

Actually, by 'this' I meant comment out 'pchigh == 0x60000000'.  And,
when I wrote 'system call' I meant a Cygwin system call like read, but
since most things are emulated on top of Win32 calls, eventually there
might be a Win32 call like ReadFile.  AFAICT, Cygwin signals are emulated
with Win32 threads and semaphores.  A Cygwin process has a "sig" thread
and a "main" thread, when a signal is sent, the "sig" thread receives it,
does a SuspendThread on the "main" thread and does a GetThreadContext,
if it is "interruptible" the context is changed and the signal handler
is pushed on the stack and the new context is set with SetThreadContext
then followed by a ResumeThread.  I can see how this could be dangerous
although I'm fairly ignorant of Win32, so I'm not sure exactly what you
can do that will leave the NT kernel in a corrupt state.

Since when running pure user code pchigh was equal to 60000000 and when
"paused on a system call" (eventually a Win32 call) pchigh was equal to
70000000, considering 60000000 as "interruptible" might be safe.

Of course, some real documentation about the contents of the Eip member
of the CONTENTS structure might help.

However, this leaves open the possibility that you might be in a Cygwin
system call (pchigh equal to 60000000?), but not in a Win32 call (pchigh
equal to 70000000?)  and interrupting the Cygwin DLL might be dangerous
to Cygwin.  I didn't test what the value of pchigh is when in a Cygwin
system call, but not a Win32 system call.  I guess I'm assuming in this
case, pchigh is equal to 60000000 and that you can't tell the difference
between being in the Cygwin DLL versus any other DLL :-(  Perhaps, Cygwin
needs a different mechanism for not interrupting the Cygwin DLL?

>>Is there a way to tell the difference between being in a normal DLL,
>>versus a "system" (what does this mean?) or cygwin DLL?
>
>Suppose there were (I don't think there is, and I don't think the notion
>of a "system" DLL even makes sense) -- how would you know that the
>"normal" DLL is not issuing a system call?  And if you can't know that,
>then you're in the case above.

Agreed.

Regards,

Eric Fifer

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


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