Repository navigation
0.26.1: a handle is retired before its descriptor is closed; one release closes; a released handle's stream is no stream - #54
Merged
Conversation
…ase closes; a released handle's stream is no stream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #53.
kal_net_close,kal_net_close_listenerandkal_datagram_closeclosed the descriptor and then retired the handle. The kernel gives a closed number to the next open in any context, so a file or a connection another context opened between the two took the number with the generation the socket's handle still had, and the retire then made its handle stale.kal_fs_streamandkal_net_streamanswered a stale handle with zero, standard input.okl::release(src/handle.h), which retires and then closes; the three closes ofopenkal.netandopenkal.datagramand the two ofopenkal.fscall it.kal_err_invalid(the report's third point; clause 6.7: a released handle is not treated as valid).tests/a_released_handle_is_stale_before_its_number_is_free.cpp: one context accepts and closes connections, one connects and closes, one opens, reads and closes a file for three seconds. Without the change: 94 files of 3.4 million read nothing of the file, and a released file's stream read standard input. With it: none.Not changed:
openfailing withkal_err_iowhen the process has no descriptor left. openkal's conditions name no exhaustion of handles, and the leak that reached it in the report is the stale handle above.The same construction is in openkal-macos (mcpplibs/openkal-macos#47) and openkal-windows.