nob__walk_dir_opt_impl() tries to close zeroed handle for non directory entries
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- operating-systems
Research direction
Start at nob__walk_dir_opt_impl() and follow its deferred call to nob_dir_entry_close(), then compare the Linux and Windows handle behavior described in the issue. The fix is done when walking non-directory entries no longer calls FindClose with a null handle or triggers the debugger, while directory walking continues normally.
Written by the indexing model from the issue text.
Description
The nob__walk_dir_opt_impl() function calls nob_dir_entry_close() in the defer, to close the current entry.
It also does this when the entry is not a directory, and therefore the directory handle is NULL.
On Linux, there is a check not to close NULL handles in the nob_dir_entry_close() function, as they are returned on erroneous open.
On Windows, on the other hand, the error handle is INVALID_HANDLE_VALUE, which is not checked anyway.
This results in calls to FindClose with a NULL handle. The result of the close function is not checked, so it continues normally in C.
But FindClose throws an exception, ending the program when used from C++, and more annoyingly triggers the debugger.
- Dominant language
- C++
- Stars
- 3.3k
- Forks
- 213
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tsoding/nob.h
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·