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: Cygwin's spawn/exec, mintty and the "Program Compatibility Assistant"


On 16 February 2012 13:39, Corinna Vinschen wrote:
> On Feb 16 13:15, Andy Koppe wrote:
>> On 16 February 2012 12:46, Corinna Vinschen wrote:
>> > Hi guys, and especially
>> > Hi Andy,
>> >
>> >
>> > A couple of weeks ago we noticed this strange problem with mintty. ÂThe
>> > "Program Compatibility Assistant" (PCA) on W7 took it under its wings
>> > for no apparent reason, and if the session was long enough you would
>> > notice that a specific svchost process, the one running the Pcasvc
>> > service, would take more and more memory and CPU time.
>> >
>> > The solution for this problem was either to ask the user to switch off
>> > the PCA service, or a change in Cygwin's spawn/exec code. Âin short, PCA
>> > sets up a Job for a controlled application, but allows to breakaway from
>> > the job. ÂThat's what Cygwin now does in *every* invocation of
>> > spawn/exec:
>> >
>> > ÂJOBOBJECT_BASIC_LIMIT_INFORMATION jobinfo;
>> > Âif (QueryInformationJobObject (NULL, JobObjectBasicLimitInformation,
>> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &jobinfo, sizeof jobinfo, NULL)
>> > Â Â Â&& (jobinfo.LimitFlags & (JOB_OBJECT_LIMIT_BREAKAWAY_OK
>> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â| JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK)))
>> > Â Â{
>> > Â Â Â/* Add CREATE_BREAKAWAY_FROM_JOB to the CreateProcess flags. */
>> > Â Â Âc_flags |= CREATE_BREAKAWAY_FROM_JOB;
>> > Â Â}
>> >
>> > While this works, what bugs me is that this additional system call takes
>> > extra time and we all know that Cygwin is slow. ÂAsk the users.
>> >
>> > I have still no idea why mintty is affected. ÂIt doesn't show up in the
>> > registry-based PCA database. ÂYesterday I found this on MSDN:
>> > http://msdn.microsoft.com/en-us/library/bb756937.aspx but I don't see
>> > anything there which would explain the effect for mintty. ÂThere's a
>> > section called "Detecting Program Failures Due to Deprecated Windows
>> > Components", maybe that's a hint?
>>
>> I'm not aware of anything. Is there any pattern to those occurrences?
>
> No, there's no pattern. ÂMintty is always grabbed by PCA for some reason.
> You can check by yourself if you build the Cygwin DLL yourself and just
> change the above debug_printf to a system_printf. ÂWhen you then start
> mintty with the new DLL, you can see that CYgwin has to free mintty out
> of the claws of PCA's job object.
>
> Or, if you disable the "c_flags |= CREATE_BREAKAWAY_FROM_JOB;", then
> run some long running make or so, observe in Task Manager how one of
> the svchost processes grab more and more memory and CPU. ÂThis can take
> some time, but it's a reliable effect.
>
> The aforementioned MSDN articel mentions something about hooking
> CoCreateInstance. ÂDoes mintty call this functions? ÂIs it possible
> that it tries to use some outdated COM object?

The only thing I can think of is the use of OLE for drag&dropping
things into the mintty window. I wouldn't be surprised if I got
something wrong there, because it's a horrible API.

You could try commenting out the win_init_drop_target() call in
winmain.c to see whether that makes a difference.

(Sorry I can't be more helpful, my spare time and energy are pretty
close to zero at the moment.)

Andy


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