Re: open() creates a new file even if it fails with EMFILE

Christian Franke via Cygwin <[email protected]> Tue, 5 May 2026 11:15:59 +0200
Newsgroups gmane.os.cygwin
Message-ID <[email protected]>
Mark Geisert via Cygwin wrote:
> Hi Christian,
>
> On 5/4/2026 11:39 AM, Christian Franke via Cygwin wrote:
>> Could be reproduced with 3.6.9 and current HEAD.
>>
>> Testcase:
>>
>> ...
>>
>> Looks like the fd is allocated too late.
>
> Thanks for the report and especially for the STC.  It is during 
> fdtable extension that the limit is checked; by then NtCreateFile() 
> has already been called successfully.  We need to consider a fix that 
> avoids needlessly creating a file that can't be operated on anyway.

You're welcome. I will add an enhanced version of the STC to the 
cygwin-apps/stc repo. Problem was detected by 'stress-ng --open ...' 
with stress-ng 0.21.01-1.

-- 
Regards,
Christian


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple