Draft
Conversation
Author
|
@krlmlr 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Copilot
AI
changed the title
[WIP] itimer state is not restored
Fix itimer state restoration in filelock
Sep 19, 2025
Copilot stopped work on behalf of
krlmlr due to an error
September 19, 2025 17:32
- Add global variable filelock_old_timer to store previous timer state - Modify setitimer call to save old timer state before setting new one - Modify alarm callback to restore both signal handler and timer state - Verified package builds and installs correctly - Tested functionality with multiple scenarios Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
e6a64e8 to
4f50835
Compare
krlmlr
reviewed
Sep 19, 2025
Member
krlmlr
left a comment
There was a problem hiding this comment.
I reviewed the code and purged useless changes but didn't change otherwise.
Member
|
@gaborcsardi: @lionel- asked me to ping you for a review. The code looks legit, but I wouldn't know how to test it. |
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.
Currently filelock restores the SIGALRM handler to its previous state but the itimer state is not restored. This can disrupt existing timers that were running before the filelock operation, such as R's profiling timer used by
Rprof().The issue occurs because while filelock correctly saves and restores the signal handler using
sigaction(), it doesn't save and restore the timer state when callingsetitimer(). This means any existing timer gets lost when filelock sets its own timer for timeout handling.Changes Made
This PR adds minimal changes to properly save and restore the itimer state:
filelock_old_timerto store the previous timer stateThe alarm callback now restores both the signal handler and the timer:
Impact
This fix allows systems like R's profiling (
Rprof()) to resume normal operation after filelock completes, as the profiling timer will be properly restored along with its interval settings. The handler will have missed some intervals during the filelock operation, but this is expected behavior since timer intervals are only a lower bound and handlers should account for this possibility.Fixes #42.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cloud.r-project.org/usr/lib/R/bin/exec/R -e install.packages(c('testthat',~+~'callr'),~+~repos='REDACTED')(dns block)cran.rstudio.com/usr/lib/R/bin/exec/R -e options(repos~+~=~+~'REDACTED');~+~install.packages(c('testthat',~+~'callr'))(dns block)esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.