[PR #1996] [MERGED] Fixed race condition in dirname and basename call #2291

Closed
opened 2026-03-04 02:04:46 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/s3fs-fuse/s3fs-fuse/pull/1996
Author: @ggtakec
Created: 7/24/2022
Status: Merged
Merged: 7/24/2022
Merged by: @gaul

Base: masterHead: fix_basename


📝 Commits (1)

  • 39d6dbe Fixed race condition in dirname and basename call

📊 Changes

3 files changed (+77 additions, -0 deletions)

View changed files

📝 src/s3fs.cpp (+20 -0)
📝 src/s3fs_util.cpp (+55 -0)
📝 src/s3fs_util.h (+2 -0)

📄 Description

Relevant Issue (if applicable)

#1987
#1994

Details

The cause of test_truncate_cache test error was a race between threads in the dirname call.(Only confirmed with macos10)

This happened because in test_truncate_cache test, s3fs_getattr was called by another thread while calling list_bucket.
Specifically, another dirname call was made shortly during receiving a static pointer from dirname and setting it to std::string buffer.
Therefore, the value set in std::string was replaced with the result called by another thread.

To fix this, we introduced mutex for exclusive control of dirname and basename(which return pointers to static variables).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/s3fs-fuse/s3fs-fuse/pull/1996 **Author:** [@ggtakec](https://github.com/ggtakec) **Created:** 7/24/2022 **Status:** ✅ Merged **Merged:** 7/24/2022 **Merged by:** [@gaul](https://github.com/gaul) **Base:** `master` ← **Head:** `fix_basename` --- ### 📝 Commits (1) - [`39d6dbe`](https://github.com/s3fs-fuse/s3fs-fuse/commit/39d6dbee194a272c99966b332a0517544cc4e1bd) Fixed race condition in dirname and basename call ### 📊 Changes **3 files changed** (+77 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/s3fs.cpp` (+20 -0) 📝 `src/s3fs_util.cpp` (+55 -0) 📝 `src/s3fs_util.h` (+2 -0) </details> ### 📄 Description ### Relevant Issue (if applicable) #1987 #1994 ### Details The cause of `test_truncate_cache` test error was a race between threads in the `dirname` call.(Only confirmed with macos10) This happened because in `test_truncate_cache` test, `s3fs_getattr` was called by another thread while calling `list_bucket`. Specifically, another `dirname` call was made shortly during receiving a static pointer from `dirname` and setting it to `std::string` buffer. Therefore, the value set in `std::string` was replaced with the result called by another thread. To fix this, we introduced `mutex` for exclusive control of `dirname` and `basename`(which return pointers to static variables). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 02:04:46 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/s3fs-fuse#2291
No description provided.