[BUG] IntelliJ plugin: Read access violation in DiffTools when opening diff view

Resolved 💬 2 comments Opened Mar 21, 2026 by the-ahodges Closed Apr 19, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

DiffTools.kt:310 calls showDiffBuiltin which triggers PSI access via PyLineWrapPositionStrategy outside a read action. Intermittent, likely a race condition during editor initialisation.
Suggested fix: wrap the call in ReadAction.run { }.

What Should Happen?

no exception

Error Messages/Logs

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action only (see Application.runReadAction()); If you access or modify model on EDT consider    
wrapping your code in WriteIntentReadAction  or ReadAction; see https://jb.gg/ij-platform-threading for details                                                                                          
Current thread: Thread[#58,AWT-EventQueue-0,10,main] 686758688 (EventQueue.isDispatchThread()=true)                                                                                                      
SystemEventQueueThread: (same)                                                                                                                                                                           
    at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:257)                                                                                       
    at com.intellij.util.concurrency.ThreadingAssertions.softAssertReadAccess(ThreadingAssertions.java:173)                                                                                              
    at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1190)                                                                                          
    at com.intellij.psi.impl.source.PsiFileImpl.assertReadAccessAllowed(PsiFileImpl.java:198)                                                                                                            
    at com.intellij.psi.impl.source.PsiFileImpl.loadTreeElement(PsiFileImpl.java:202)                                                                                                                    
    at com.intellij.psi.impl.source.PsiFileImpl.getTreeElement(PsiFileImpl.java:125)                                                                                                                     
    at com.intellij.psi.impl.source.PsiFileImpl.calcTreeElement(PsiFileImpl.java:840)                                                                                                                    
    at com.intellij.psi.impl.source.PsiFileImpl.getNode(PsiFileImpl.java:1040)                                                                                                                           
    at com.intellij.psi.impl.source.PsiFileImpl.getNode(PsiFileImpl.java:55)                                                                                                                             
    at com.intellij.psi.AbstractFileViewProvider.findElementAt(AbstractFileViewProvider.java:237)                                                                                                        
    at com.intellij.psi.SingleRootFileViewProvider.findElementAt(SingleRootFileViewProvider.java:242)                                                                                                    
    at com.intellij.psi.impl.source.PsiFileImpl.findElementAt(PsiFileImpl.java:551)                                                                                                                      
    at com.jetbrains.python.formatter.PyLineWrapPositionStrategy.calculateWrapPosition(PyLineWrapPositionStrategy.java:76)                                                                               
    at com.intellij.openapi.editor.impl.SoftWrapEngine.calcSoftWrapOffset(SoftWrapEngine.java:188)                                                                                                       
    at com.intellij.openapi.editor.impl.SoftWrapEngine.createSoftWrap(SoftWrapEngine.java:156)                                                                                                           
    at com.intellij.openapi.editor.impl.SoftWrapEngine.generate(SoftWrapEngine.java:128)                                                                                                                 
    at com.intellij.openapi.editor.impl.softwrap.mapping.SoftWrapApplianceManager.recalculateSoftWraps(SoftWrapApplianceManager.java:232)                                                                
    at com.intellij.openapi.editor.impl.softwrap.mapping.SoftWrapApplianceManager.recalculateSoftWraps(SoftWrapApplianceManager.java:203)                                                                
    at com.intellij.openapi.editor.impl.softwrap.mapping.SoftWrapApplianceManager.recalculateIfNecessary(SoftWrapApplianceManager.java:363)                                                              
    at com.intellij.openapi.editor.impl.SoftWrapModelImpl.prepareToMapp                                                                                                                                  
… +113 lines …                                                                                                                                                                                           
333)                                                                                                                                                                                                     
    at com.intellij.concurrency.ThreadContext.resetThreadContext(threadContext.kt:294)                                                                                                                   
    at com.intellij.openapi.application.impl.NonBlockingFlushQueue.runNextEvent$lambda$1(NonBlockingFlushQueue.kt:330)                                                                                   
    at com.intellij.platform.locking.impl.NestedLocksThreadingSupport.tryRunWriteIntentReadAction(NestedLocksThreadingSupport.kt:689)                                                                    
    at com.intellij.openapi.application.impl.NonBlockingFlushQueue.runNextEvent(NonBlockingFlushQueue.kt:326)                                                                                            
    at com.intellij.openapi.application.impl.NonBlockingFlushQueue.flushNow(NonBlockingFlushQueue.kt:305)                                                                                                
    at com.intellij.openapi.application.impl.NonBlockingFlushQueue.FLUSH_NOW$lambda$0(NonBlockingFlushQueue.kt:167)                                                                                      
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)                                                                                                                    
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)                                                                                                                           
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)                                                                                                                                       
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)                                                                                                                                       
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)                                                                                                                  
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)                                                                                 
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)                                                                                                                               
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:664)                                                                                                                         
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:517)                                                                                                                               
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$0$0$0(IdeEventQueue.kt:333)                                                                                                                   
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1065)                                                                                                                  
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:109)                                                                                              
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1065)                                                                                                                           
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$0(IdeEventQueue.kt:331)                                                                                                                       
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:371)                                                                                                                                
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)                                                                                                    
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)                                                                                                       
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)                                                                                                    
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)                                                                                                                
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)                                                                                                                
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)                                                                                                                        
                                                                                                                                                                                                         

● Let me look at the relevant plugin code.

  Searched for 2 patterns (ctrl+o to expand)

● This stack trace is from the Claude Code IntelliJ plugin itself (com.anthropic.code.plugin), not from your project code. The exception originates at DiffTools.kt:310 in the plugin.

  The root cause: the plugin's DiffTools is calling DiffManager.showDiffBuiltin (which triggers PSI access via PyLineWrapPositionStrategy) from a lambda that runs outside a read action, despite being
  on the EDT.

  Since this is in the plugin internals and not your project code, you can't fix it directly. A few options:

  1. Report it — file a bug at https://github.com/anthropics/claude-code/issues with this stack trace. The fix needed is to wrap the showDiffBuiltin call (or the surrounding PSI-touching code) in
  ReadAction.run { } or runReadAction { }.
  2. Workaround — if this happens when viewing diffs in the plugin, try triggering the diff view differently (e.g., from a different context or after the editor has fully loaded).

  The specific fix in the plugin would be at DiffTools.kt:310 — the lambda calling showDiffBuiltin needs to be wrapped in a read action, something like:

  ReadAction.run<Throwable> {
      DiffManager.getInstance().showDiff(project, request)
  }

  Or the call should be deferred until after the editor has finished initializing, since the trace shows it's being triggered during scroll position setup (InitialScrollPositionSupport).

  Is this happening consistently (e.g., every time you open a diff), or was it a one-off?

❯ no it was a one-off, as far as I can tell                                                                                                                                                              

● Good to know — likely a race condition during editor initialization that resolved itself. If it recurs consistently, worth filing a bug report, but for now you can ignore it.

❯ can you not file bug report on yourself? It would seem like a useful function                                                                                                                          

● I could try — I have access to the gh CLI which can create GitHub issues. But filing an issue on a public repo is an action visible to others, so I'd want your confirmation before doing it.

  Want me to go ahead and file it against anthropics/claude-code?

❯ yes why not                                                                                                                                                                                            

● Bash(gh issue create --repo anthropics/claude-code --title "IntelliJ plugin: Read access violation in DiffTools when opening diff view" --body "$(cat <<'EOF'
      ## Desc…)
  ⎿        0 [main] bash (48852) C:\Program Files\Git\bin\..\usr\bin\bash.exe: *** fatal error - add_item ("\??\C:\Program Files\Git", "/", ...) failed, errno 1

● That failed due to a Git Bash environment issue on Windows. Let me try with PowerShell instead:

● Bash(gh issue create --repo anthropics/claude-code --title "IntelliJ plugin: Read access violation in DiffTools when opening diff view" --body "## Description…)
  ⎿  Running…

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 Bash command

   gh issue create --repo anthropics/claude-code --title "IntelliJ plugin: Read access violation in DiffTools when opening diff view" --body "## Description

   A \`RuntimeExceptionWithAttachments\` occurs in the IntelliJ plugin when opening a diff view. PSI is being accessed outside a read action.

   ## Stack trace (key frames)

   \`\`\`
   com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action only
       at com.intellij.psi.impl.source.PsiFileImpl.loadTreeElement(PsiFileImpl.java:202)
       at com.jetbrains.python.formatter.PyLineWrapPositionStrategy.calculateWrapPosition(PyLineWrapPositionStrategy.java:76)
       at com.intellij.openapi.editor.impl.SoftWrapEngine.calcSoftWrapOffset(SoftWrapEngine.java:188)
       at com.intellij.diff.tools.util.base.InitialScrollPositionSupport\$TwosideInitialScrollHelper.performDelayedSyncScroll(InitialScrollPositionSupport.java:138)
       at com.anthropic.code.plugin.mcp.tools.DiffTools\$addTools\$1.invokeSuspend\$lambda\$12(DiffTools.kt:310)
       at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:239)
   \`\`\`

   ## Root cause

   \`DiffTools.kt:310\` calls \`showDiffBuiltin\` which triggers PSI access via \`PyLineWrapPositionStrategy\` during soft wrap calculation, outside a read action.

   ## Suggested fix

   Wrap the \`showDiffBuiltin\` call in a read action, or ensure the diff opens after the editor has fully initialised (since the exception fires during \`InitialScrollPositionSupport\` scroll
   setup).

   ## Environment

   - IDE: IntelliJ IDEA (with Python plugin)
   - OS: Windows 11 Pro
   - Occurrence: intermittent (likely a race condition during editor initialisation)" 2>&1
   Create GitHub issue using gh CLI

 Command contains a quoted newline followed by a #-prefixed line, which can hide arguments from line-based permission checks

 Do you want to proceed?
 ❯ 1. Yes
   2. No

 Esc to cancel · Tab to amend · ctrl+e to explain
╭─── Claude Code v2.1.81 ────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                    │ Tips for getting started                                          │
│                 Welcome back Alan!                 │ Run /init to create a CLAUDE.md file with instructions for Claude │
│                                                    │ ───────────────────────────────────────────────────────────────── │
│                       ▐▛███▜▌                      │ Recent activity                                                   │
│                      ▝▜█████▛▘                     │ No recent activity                                                │
│                        ▘▘ ▝▝                       │                                                                   │
│ Sonnet 4.6 · Claude Pro ·                          │                                                                   │
│ ahodges@carriagereturnsoftware.com.'s Organization │                                                                   │
│      D:\alan\Development\Fire Matters\fcwa-39      │                                                                   │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

  ✻ Voice mode is now available · /voice to enable

❯ this plugin had an exception yesterday:                                                                                                                                                                
com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action only (see Application.runReadAction()); If you access or modify model on EDT consider    
wrapping your code in WriteIntentReadAction  or ReadAction; see https://jb.gg/ij-platform-threading for details                                                                                          
Current thread: Thread[#58,AWT-EventQueue-0,10,main] 686758688 (EventQueue.isDispatchThread()=true)                                                                                                      
SystemEventQueueThread: (same)                                                                                                                                                                           
    at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:257)                                                                                       
    at com.intellij.util.concurrency.ThreadingAssertions.softAssertReadAccess(ThreadingAssertions.java:173)                                                                                              
    at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1190)                                                                                          
    at com.intellij.psi.impl.source.PsiFileImpl.assertReadAccessAllowed(PsiFileImpl.java:198)                                                                                                            
    at com.intellij.psi.impl.source.PsiFileImpl.loadTreeElement(PsiFileImpl.java:202)                                                                                                                    
    at com.intellij.psi.impl.source.PsiFileImpl.getTreeElement(PsiFileImpl.java:125)                                                                                                                     
    at com.intellij.psi.impl.source.PsiFileImpl.calcTreeElement(PsiFileImpl.java:840)                                                                                                                    
    at com.intellij.psi.impl.source.PsiFileImpl.getNode(PsiFileImpl.java:1040)                                                                                                                           
    at com.intellij.psi.impl.source.PsiFileImpl.getNode(PsiFileImpl.java:55)                                                                                                                             
    at com.intellij.psi.AbstractFileViewProvider.findElementAt(AbstractFileViewProvider.java:237)                                                                                                        
    at com.intellij.psi.SingleRootFileViewProvider.findElementAt(SingleRootFileViewProvider.java:242)                                                                                                    
    at com.intellij.psi.impl.source.PsiFileImpl.findElementAt(PsiFileImpl.java:551)                                                                                                                      
    at com.jetbrains.python.formatter.PyLineWrapPositionStrategy.calculateWrapPosition(PyLineWrapPositionStrategy.java:76)                                                                               
    at com.intellij.openapi.editor.impl.SoftWrapEngine.calcSoftWrapOffset(SoftWrapEngine.java:188)                                                                                                       
    at com.intellij.openapi.editor.impl.SoftWrapEngine.createSoftWrap(SoftWrapEngine.java:156)                                                                                                           
    at com.intellij.openapi.editor.impl.SoftWrapEngine.generate(SoftWrapEngine.java:128)                                                                                                                 
    at com.intellij.openapi.editor.impl.softwrap.mapping.SoftWrapApplianceManager.recalculateSoftWraps(SoftWrapApplianceManager.java:232)                                                                
    at com.intellij.openapi.editor.impl.softwrap.mapping.SoftWrapApplianceManager.recalculateSoftWraps(SoftWrapApplianceManager.java:203)                                                                
    at com.intellij.openapi.editor.impl.softwrap.mapping.SoftWrapApplianceManager.recalculateIfNecessary(SoftWrapApplianceManager.java:363)                                                              
    at com.intellij.openapi.editor.impl.SoftWrapModelImpl.prepareToMapp                                                                                                                                  
… +113 lines …                                                                                                                                                                                           
333)                                                                                                                                                                                                     
    at com.intellij.concurrency.ThreadContext.resetThreadContext(threadContext.kt:294)                                                                                                                   
    at com.intellij.openapi.application.impl.NonBlockingFlushQueue.runNextEvent$lambda$1(NonBlockingFlushQueue.kt:330)                                                                                   
    at com.intellij.platform.locking.impl.NestedLocksThreadingSupport.tryRunWriteIntentReadAction(NestedLocksThreadingSupport.kt:689)                                                                    
    at com.intellij.openapi.application.impl.NonBlockingFlushQueue.runNextEvent(NonBlockingFlushQueue.kt:326)                                                                                            
    at com.intellij.openapi.application.impl.NonBlockingFlushQueue.flushNow(NonBlockingFlushQueue.kt:305)                                                                                                
    at com.intellij.openapi.application.impl.NonBlockingFlushQueue.FLUSH_NOW$lambda$0(NonBlockingFlushQueue.kt:167)                                                                                      
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)                                                                                                                    
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)                                                                                                                           
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)                                                                                                                                       
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)                                                                                                                                       
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)                                                                                                                  
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)                                                                                 
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)                                                                                                                               
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:664)                                                                                                                         
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:517)                                                                                                                               
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$0$0$0(IdeEventQueue.kt:333)                                                                                                                   
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1065)                                                                                                                  
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:109)                                                                                              
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1065)                                                                                                                           
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$0(IdeEventQueue.kt:331)                                                                                                                       
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:371)                                                                                                                                
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)                                                                                                    
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)                                                                                                       
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)                                                                                                    
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)                                                                                                                
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)                                                                                                                
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

Steps to Reproduce

I don't know - it was reported on PyCharm open project a day after the exception occurred

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

v2.1.81

Platform

Other

Operating System

Windows

Terminal/Shell

IntelliJ IDEA terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗