Skip to content

Comments

fix(dev): avoid mutex deadlock caused by inconsistent lock order#8370

Merged
graphite-app[bot] merged 1 commit intomainfrom
02-18-fix_dev_avoid_mutex_deadlock_caused_by_inconsistent_lock_order
Feb 19, 2026
Merged

fix(dev): avoid mutex deadlock caused by inconsistent lock order#8370
graphite-app[bot] merged 1 commit intomainfrom
02-18-fix_dev_avoid_mutex_deadlock_caused_by_inconsistent_lock_order

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Feb 18, 2026

The lock order of bundler and clients were inconsistent. This potentially causes deadlocks (e.g. when one thread locks bundler and another thread locks clients).

  • bundler -> clients
    • let mut bundler = self.bundler.lock().await;
      let changed_files = self
      .input
      .changed_files()
      .iter()
      .map(|(p, event)| (p.to_string_lossy().to_string(), *event))
      .collect::<FxIndexMap<_, _>>();
      // Build ClientHmrInput for each client
      // Store client sessions to keep data alive during HMR computation
      let client_sessions: Vec<_> = self.dev_context.clients.iter().collect();
  • clients -> bundler
    • for client in self.clients.iter() {
      let mut bundler = self.bundler.lock().await;
    • // Get executed modules for this client
      let executed_modules =
      self.clients.get(&client_id).map(|c| c.executed_modules.clone()).unwrap_or_default();
      // Mark the proxy module as fetched BEFORE compilation.
      // This changes the content returned by the lazy compilation plugin's load hook
      // from a stub (fetches via /lazy endpoint) to actual code that imports the real module.
      let mut bundler = self.bundler.lock().await;

This PR changes all to bundler -> clients.

Copy link
Member Author

sapphi-red commented Feb 18, 2026


How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@netlify
Copy link

netlify bot commented Feb 18, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit fc69283
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6996720371f3e70008ba4849

@sapphi-red sapphi-red force-pushed the 02-18-fix_dev_avoid_mutex_deadlock_caused_by_inconsistent_lock_order branch from 6e9caf0 to 8dc5a71 Compare February 18, 2026 10:09
@sapphi-red sapphi-red marked this pull request as ready for review February 18, 2026 10:31
Copilot AI review requested due to automatic review settings February 18, 2026 10:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical deadlock issue in the rolldown dev server caused by inconsistent lock ordering between the bundler mutex and clients concurrent map. The fix ensures all code paths follow a consistent bundlerclients lock order.

Changes:

  • Moved bundler.lock() acquisition to occur before accessing clients in two methods
  • Established consistent lock ordering throughout the codebase to prevent circular wait conditions

@sapphi-red sapphi-red requested a review from hyf0 February 18, 2026 10:38
@github-actions
Copy link
Contributor

github-actions bot commented Feb 18, 2026

Benchmarks Rust

  • target: main(f6ca0aa)
  • pr: 02-18-fix_dev_avoid_mutex_deadlock_caused_by_inconsistent_lock_order(23afd7b)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     70.2±2.28ms        ? ?/sec    1.03     72.2±2.11ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     76.2±1.99ms        ? ?/sec    1.03     78.6±2.62ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    101.7±4.13ms        ? ?/sec    1.01    102.5±1.91ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    111.7±1.62ms        ? ?/sec    1.01    113.3±1.79ms        ? ?/sec
bundle/bundle@threejs                                        1.00     37.2±2.35ms        ? ?/sec    1.00     37.3±1.95ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     41.0±0.82ms        ? ?/sec    1.01     41.3±0.76ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    363.7±4.76ms        ? ?/sec    1.02    371.0±6.47ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    419.6±3.54ms        ? ?/sec    1.01    423.8±6.34ms        ? ?/sec
scan/scan@rome_ts                                            1.00     78.8±1.24ms        ? ?/sec    1.01     79.4±1.56ms        ? ?/sec
scan/scan@threejs                                            1.00     28.0±2.20ms        ? ?/sec    1.01     28.3±1.73ms        ? ?/sec
scan/scan@threejs10x                                         1.00    271.7±5.38ms        ? ?/sec    1.02    276.6±3.46ms        ? ?/sec

@sapphi-red sapphi-red force-pushed the 02-18-fix_dev_avoid_mutex_deadlock_caused_by_inconsistent_lock_order branch from 8dc5a71 to 23afd7b Compare February 18, 2026 10:59
Copy link
Member Author

sapphi-red commented Feb 19, 2026

Merge activity

  • Feb 19, 2:13 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Feb 19, 2:13 AM UTC: sapphi-red added this pull request to the Graphite merge queue.
  • Feb 19, 2:25 AM UTC: Merged by the Graphite merge queue.

Copilot AI review requested due to automatic review settings February 19, 2026 02:14
@graphite-app graphite-app bot force-pushed the 02-18-fix_dev_avoid_mutex_deadlock_caused_by_inconsistent_lock_order branch from 23afd7b to fc69283 Compare February 19, 2026 02:14
@sapphi-red sapphi-red review requested due to automatic review settings February 19, 2026 02:14
@graphite-app graphite-app bot merged commit fc69283 into main Feb 19, 2026
34 checks passed
@graphite-app graphite-app bot deleted the 02-18-fix_dev_avoid_mutex_deadlock_caused_by_inconsistent_lock_order branch February 19, 2026 02:25
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