Skip to content

Stop reusing fd - #1752

Merged
soutaro merged 1 commit into
masterfrom
fix-ebadf
Feb 8, 2024
Merged

soutaro merged 1 commit into
masterfrom
fix-ebadf

Conversation

@soutaro

@soutaro soutaro commented Feb 8, 2024

Copy link
Copy Markdown
Member

An error is reported in ruby CI.

Error: test_file?(FileTestSingletonTest): Errno::EBADF: Bad file descriptor
  test/stdlib/FileTest_test.rb:13:in `close'

We find there are reusing a fd in test. So, we assume the EBADF is happening by:

  1. sysopen in IO_test returns a file descriptor N
  2. N is passed to two IO.open calls during test
  3. The first IO instance is closed by GC, but the second one is still alive
  4. The sysopen in FileTest_test returns N, so another IO instance with the file descriptor is created
  5. There are two IO instances associated to N, one created in IO_test, other created in FileTest_test
  6. IO is closed by GC successfully, because N is opened in FileTest_test
  7. Calling close in FileTest_test raises an error, because N is already closed

We hope this fix solves the problem. 🤞

@soutaro soutaro added this to the RBS 3.5 milestone Feb 8, 2024
@soutaro
soutaro added this pull request to the merge queue Feb 8, 2024
Merged via the queue into master with commit 3b4b710 Feb 8, 2024
@soutaro
soutaro deleted the fix-ebadf branch February 8, 2024 13:36
soutaro added a commit that referenced this pull request Feb 8, 2024
@soutaro soutaro mentioned this pull request Feb 8, 2024
soutaro added a commit that referenced this pull request Feb 8, 2024
@soutaro soutaro added the Released PRs already included in the released version label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Released PRs already included in the released version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant