Skip to content

Set perf_event_paranoid=1 in WSL init to fix rr debugger on WSL 6.18#40937

Draft
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-rr-debugger-failure
Draft

Set perf_event_paranoid=1 in WSL init to fix rr debugger on WSL 6.18#40937
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-rr-debugger-failure

Conversation

Copilot AI commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

rr 5.9.0 fails on WSL 2.7.8/2.7.9 (kernel 6.18). Kernel 6.18 added MADV_GUARD_INSTALL (102); glibc 2.42+ (Ubuntu 26.04) calls it for thread stack guards via pthread_create. rr 5.9.0 intercepts it, expects EINVAL (unknown advise), gets 0 (success), assertion fires, process crashes. Fixed in rr 5.9.1+.

Summary of the Pull Request

Set perf_event_paranoid=1 in the WSL init, which is the standard requirement for rr on WSL2. Previously users had to set this manually via /etc/sysctl.d/.

PR Checklist

  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

perf_event_paranoid=2 (kernel default) blocks hardware perf counter access for unprivileged users. rr needs level <=1 to open PERF_TYPE_HARDWARE events for traced processes. WSL init now sets this automatically so rr works out-of-the-box when wsl2.hardwarePerformanceCounters=true (the default on x86-64).

The MADV_GUARD_INSTALL crash in rr 5.9.0 is a rr bug fixed upstream in rr 5.9.1. Users on WSL 2.7.8+ should upgrade to rr 5.9.1+.

Change: src/linux/init/main.cpp — added WriteToFile("/proc/sys/kernel/perf_event_paranoid", "1\n") in Initialize().

Validation Steps Performed

  • Verified perf_event_paranoid sysctl exists and is writable at init time.
  • Change is consistent with existing WriteToFile sysctl pattern in Initialize().

Copilot AI requested review from Copilot and removed request for Copilot June 27, 2026 18:18
Copilot AI requested review from Copilot and removed request for Copilot June 27, 2026 19:09
Copilot AI changed the title [WIP] Fix rr debugger failure with versions 2.7.8 and 2.7.9 Set perf_event_paranoid=1 in WSL init to fix rr debugger on WSL 6.18 Jun 27, 2026
Copilot AI requested a review from benhillis June 27, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants