Skip to content

Conversation

@Bodigrim
Copy link
Contributor

@Bodigrim Bodigrim commented Nov 5, 2020

As dicovered in #311, certain tests fail for Windows build with GHC 8.10: DeleteFile "\\\\?\\D:\\a\\bytestring\\bytestring\\tests\\qc-test-ThreadId 5": permission denied (The process cannot access the file because it is being used by another process.), emitted by System.Directory.removeFile, invoked in Properties.hs.

bytestring/tests/Properties.hs

Lines 1609 to 1616 in a83b778

prop_read_write_file_L x = ioProperty $ do
tid <- myThreadId
let f = "qc-test-"++show tid
bracket
(do L.writeFile f x)
(const $ do removeFile f)
(const $ do y <- L.readFile f
return (x==y))

It's actually amazing that these tests have worked for ages under all other platforms, because they are reference examples of lazy I/O done wrong. Clearly the file is unlinked before its content is read in full. And bracket is useless here, because there is no resource to capture. One must explicitly force evaluation of lazy bytestring before removing the file.

@vdukhovni
Copy link
Contributor

It's actually amazing that these tests have worked for ages under all other platforms, because they are reference examples of lazy I/O done wrong. Clearly the file is unlinked before its content is read in full.

Of course unlinking of open files, or conversely reading open, but unlinked files is expected POSIX behaviour, so the surprise is not really so great... While Haskell prefers to prevent overlapping open for write, the underlying Unix O/S imposes no such limitations, and nothing in haskell prevents unlinking of open files, so that particular restriction is just then a feature of the Windows API.

@Bodigrim
Copy link
Contributor Author

Bodigrim commented Nov 8, 2020

Ah, now it makes sense. Thanks.

Copy link
Member

@sjakobi sjakobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers! :)

@Bodigrim Bodigrim merged commit 059af04 into haskell:master Nov 10, 2020
@Bodigrim Bodigrim added this to the 0.11.1.0 milestone Nov 18, 2020
@Bodigrim Bodigrim deleted the fix-io-tests branch November 18, 2020 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants