Title: Race condition in multithreading environment due to usage of os.chdir · Issue #1052 · gitpython-developers/GitPython · GitHub
Open Graph Title: Race condition in multithreading environment due to usage of os.chdir · Issue #1052 · gitpython-developers/GitPython
X Title: Race condition in multithreading environment due to usage of os.chdir · Issue #1052 · gitpython-developers/GitPython
Description: Hi, I recently ran into a race condition when using two different instances of git.Repo objects in two different threads. Inside repo.index.add(), some functions are decorated with the git_working_dir decorator. This decorator changes th...
Open Graph Description: Hi, I recently ran into a race condition when using two different instances of git.Repo objects in two different threads. Inside repo.index.add(), some functions are decorated with the git_working_...
X Description: Hi, I recently ran into a race condition when using two different instances of git.Repo objects in two different threads. Inside repo.index.add(), some functions are decorated with the git_working_...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1052
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Race condition in multithreading environment due to usage of os.chdir","articleBody":"Hi, \r\n\r\nI recently ran into a race condition when using two different instances of `git.Repo` objects in two different threads. \r\n\r\nInside `repo.index.add()`, some functions are decorated with the `git_working_dir` decorator. This decorator changes the process working directory to the one of repository, performs some system calls, then returns the working dir back to the initial value. \r\n\r\nIf two threads perform `repo.index.add()`, even on two independent `Repo()` objects, the working directory of the entire process could be permanently modified. Moreover, system calls done by `index.add()` may fail. For example `lstat()` will be executed with a relative file name assuming a wrong absolute path.\r\n\r\nFor example: \r\n1. working dir (wd) is /home/user\r\n2. git_working_dir is entered in thread 1. (/home/user is registered, wd changed to /repo1)\r\n3. git_working_dir is entered in thread 2. (/repo1 is registered, wd changed to /repo2)\r\n4. git_working_dir is exited in thread 1. (wd restored to /home/user)\r\n5. git_working_dir is exited in thread 2. (wd restored to /repo1)\r\nnow the process wd is /repo1\r\n\r\nI believe I could work around this issue by creating git object directly rather than adding to the index then committing, but I thought you may be interested to know about the issue. \r\n\r\nRadu\r\n\r\n","author":{"url":"https://github.com/rcarpa","@type":"Person","name":"rcarpa"},"datePublished":"2020-09-02T07:15:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/1052/GitPython/issues/1052"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:49843e3c-1325-68d8-ebe4-0ef7f7d4daac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9AE2:195C66:57BEF1:7ACE25:6968CB50 |
| html-safe-nonce | 15d0687d5754a1fce55b7e79250c2c1761b7658bfc381740f8cdcb900d58bb83 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUUyOjE5NUM2Njo1N0JFRjE6N0FDRTI1OjY5NjhDQjUwIiwidmlzaXRvcl9pZCI6IjIzMDc5MTA4MjI5ODY4Mjg2MjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 40b27f6bf34977b637243b0fffcf1ebfc5923dc359f85295de66383f5065fe33 |
| hovercard-subject-tag | issue:690782515 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/1052/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dc0ffb67c78047c460b2d50ae167bf308fa4e8598fad3ee1857ef244ac4ce8ef/gitpython-developers/GitPython/issues/1052 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dc0ffb67c78047c460b2d50ae167bf308fa4e8598fad3ee1857ef244ac4ce8ef/gitpython-developers/GitPython/issues/1052 |
| og:image:alt | Hi, I recently ran into a race condition when using two different instances of git.Repo objects in two different threads. Inside repo.index.add(), some functions are decorated with the git_working_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rcarpa |
| hostname | github.com |
| expected-hostname | github.com |
| None | af2d7af0cc84117fa10bf36808605ef68a335c9d8a804b9cdac55f8d77230b00 |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cc844ab6ee0198cc2e2c142dcb8a5c2a61d48743 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width