Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Error - Unhandled exception - Write Lock / Read Lock Deadlock
Collapse
X
-
-
Hello Shai Samuel,
Without specific steps to reproduce the problem there is not a lot we can do to assist with this error. This error message can be observed after a script causes a problem. Generally when you see this error the chart was already frozen and the error is produced upon closing the chart which is not helpful to know the original reason that was causing problems in the chart.
If you have custom items applied in the chart or workspace a starting point would be to remove those items and find when the error stops happening, that may help to isolate a specific item that is causing that to happen. If you have a way to reproduce the error you could further test to see what steps or items are required to get the error.
Comment
-
Dear Jesse,
I believe I have a clue and thought it would be of value to share it with you and the community.
What is required is to read the error message and look for clues where the issue is. In my case, what jumped into my eyes is the multiple references to RemoveBars.
The barType I am using is once I wrote, and I am using the removebar option in it. I did find I was calling
where the help guide recommends usingCode:bars.RemoveLastBar();
I did fix it and hope this will help.Code:RemoveLastBar(bars);
Here is the original error message:
Code:[LIST][*][*]2023-08-09 08:38:39:611 Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock. 2023-08-09 08:38:39:613 System.Threading.LockRecursionException: Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock. at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLockCore(TimeoutTracker timeout) at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLock(TimeoutTracker timeout) at NinjaTrader.Data.BarsSeries.Dispose() at NinjaTrader.Data.Bars.Dispose(Boolean disposing) at NinjaTrader.Gui.Chart.ChartControl.<>c__Disp layCla ss595_0.<RemoveBars>b__0() at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout) at System.Windows.Threading.Dispatcher.Invoke(Action callback) at NinjaTrader.Gui.Chart.ChartControl.RemoveBars(Char tBars chartBars) at NinjaTrader.Gui.Chart.ChartControl.RemoveBarsFromB arsArray(ChartBars chartBars) at NinjaTrader.Gui.Chart.ChartControl.RemovePanel(Cha rtPanel panel, Boolean notifyUi) at NinjaTrader.Gui.Chart.ChartControl.Cleanup() at NinjaTrader.Gui.Chart.ChartTab.Cleanup() at NinjaTrader.Gui.Tools.NTWindow.CleanTabs(TabContro l tabControl, Int32 idx) at NinjaTrader.Gui.Tools.NTWindow.OnClosed(EventArgs e) at System.Windows.Window.WmDestroy() at System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.PublicHooksFilte rMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation( Object o) at System.Windows.Threading.ExceptionWrapper.Internal RealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatch When(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) [LIST][/LIST][LIST][*]Edit[*]Quote[*]Flag[*]Like0[/LIST][*][/LIST]
Comment
-
Dear Jesse,
I believe I have a clue and thought it would be of value to share it with you and the community.
What is required is to read the error message and look for clues where the issue is. In my case, what jumped into my eyes is the multiple references to RemoveBars.
The barType I am using is once I wrote, and I am using the removebar option in it. I did find I was calling
where the help guide recommends usingCode:bars.RemoveLastBar();
I did fix it and hope this will help.Code:RemoveLastBar(bars);
Here is the original error message, which I broke down to show where the clue is:
Here is the RemoveBars error:2023-08-09 08:38:39:611 Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock.
2023-08-09 08:38:39:613 System.Threading.LockRecursionException: Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock.
at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLockCore(TimeoutTracker timeout)
at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLock(TimeoutTracker timeout)
at NinjaTrader.Data.BarsSeries.Dispose()
at NinjaTrader.Data.Bars.Dispose(Boolean disposing)
at NinjaTrader.Gui.Chart.ChartControl.<>c__Disp layCla ss595_0.<RemoveBars>b__0()
at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke(Action callback)
at NinjaTrader.Gui.Chart.ChartControl.RemoveBars(Char tBars chartBars)
at NinjaTrader.Gui.Chart.ChartControl.RemoveBarsFromB arsArray(ChartBars chartBars)
at NinjaTrader.Gui.Chart.ChartControl.RemovePanel(Cha rtPanel panel, Boolean notifyUi)at NinjaTrader.Gui.Chart.ChartControl.Cleanup()
at NinjaTrader.Gui.Chart.ChartTab.Cleanup()
at NinjaTrader.Gui.Tools.NTWindow.CleanTabs(TabContro l tabControl, Int32 idx)
at NinjaTrader.Gui.Tools.NTWindow.OnClosed(EventArgs e)
at System.Windows.Window.WmDestroy()
at System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.PublicHooksFilte rMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation( Object o)
at System.Windows.Threading.ExceptionWrapper.Internal RealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatch When(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)Last edited by Shai Samuel; 08-09-2023, 02:32 PM.
Comment
-
Hello Shai Samuel,
You can try that however RemoveBars is not the same as RemoveLastBar. The items listed in the error are the type of method calls that would happen when closing a chart window. The times which I have seen this error it was not related to the overall issue in the custom items logic but was a result of the chart being frozen.
If you are using custom bars types of other items on the chart it would be best to first try and find a specific way to reproduce the issue reliably and then start removing customizations to see if the base chart without any extras still has a problem.
Comment
-
Another NT 8117 freeze event today, 37 seconds before close of US equities markets in fast market conditions. At the time, there was no user interaction with NT other than moving the mouse cursor (crosshair) across a chart. Initially, two charts froze - the one that the mouse cursor was passing over, and the chart next to it. Those two charts were totally unresponsive, with all market data updating stopped and with no visible mouse cursor. The other charts of that symbol also had stopped data, but the mouse crosshair still appeared normal when moving over those charts. Tabbed charts with other market symbols continued to display current market data, and so did the Market Analyzer, DOM, and T&S.
When attempting to close the workspace normally using Control Center, clicking on Workspaces > (workspacename) > close, caused Control Center to freeze and become totally unresponsive. To close NT, Task Manager > End Task was required. Prior to ending the NT process, Task Manager did not show NT as "Not Responding", and CPU, Memory, GPU, and other columns all were updating and looked normal. In the process of NT closing, an NT error message window popped up but closed too quickly to read it. Probably it was the usual write lock / read lock error message that displays at that point when End Task is used to close NT after these freeze events. Checking NT Trace and Log files, there were no indicative line items whatsoever. Also nothing in Windows Event Viewer.
Comment
-
Hello Lancer,
If you are not sure if you had received the same error message as was posted earlier in this thread it likely was not the same problem. I would suggest opening a new post of your own if you are having freezing problems and not seeing the write lock error message in the logs. If you have third party items being used in the workspace it could have been related to one of those items. What you described sounds like an item was freezing the charts in fast market conditions but the data feed was still working. If charts are frozen and you try to close the workspace that could cause additional problems while shutting down that would require using the task manager.
Comment
-
Hello Lancer,
If you don't have a specific error message in the log that relates to this post I would suggest opening a new thread for that issue and provide any relevant details on how to reproduce the problem. This post already contains all of the information needed to try and debug the situation further on your end. Adding additional comments each time you see a problem is not going to assist in finding an answer to the original posts question because we don't have any details on what may be causing the problem. You would still need to find a common cause or set of steps that leads to that result so we can better understand what the problem is and how to address it.
Comment
-
Some other discussion threads about this issue:
Charts Crashing: Write lock may not be acquired with read lock held
Deadlock Error
NT freezing
That's not all of them.
Comment
-
Hello Lancer,
Yes this is a generic error which can occur for various reasons so there is not one single solution. If you are hitting this error when using only the platform and nothing third party or custom we would need to know what steps you used to see that. If you otherwise see this when something custom is being used we would need more specific details about what was used and the steps that were followed. If that is being caused with something custom that you made you would additionally need to debug the script and use the steps you found that causes the error to find what code is related.
This type of error can be caused by threading problems as explained in one of the posts you linked. This can also be caused with rendering problems such as using brushes incorrectly with sharpdx. We would still need a specific use case to be able to narrow down the problem in your specific situation.
Comment
-
Another NT 8117 freeze event today. At the time, there was no user interaction with NT. One tabbed NQ chart froze - the one that the mouse cursor was left on with the PC unattended. That chart was totally unresponsive, with all market data updating stopped and with no mouse cursor visible. The other tabbed NQ charts also had stopped data updating, except for Bid/Ask updating on chart trader that continued to update. The mouse crosshair still appeared normal when moving over the other NQ charts, and other chart functionality remained such as clicks on toolbar items, just no market data updating. Tabbed charts with other market symbols continued to display current market data, and so did the Market Analyzer, DOM, and T&S. When minimizing and restoring the whole NT workspace, the frozen NQ chart did not restore, only the chart border with toolbar and tabs.
No indication of anything in log and trace files. All charts, whichever one that freezes, and the others that don't freeze and continue updating data, are all configured the same; the same setup and indicators, nothing new.
Reluctant to try the newest v8.1.2.1 as a possible fix due to it's own reported issues.
NT support, with absolutely no leads for troubleshooting in log and trace files or elsewhere, I don't expect that you can offer any solutions, just know that this behavior is continuing for me and many others as reported in this and other threads on this subject.
Comment
-
Hello Lancer,
Yes in this case with no new leads we would not be able to know what the problem is. I would suggest doing a clean install of the current release and if you continue to have problems you can use the steps previously listed in this thread to troubleshoot that further. In this type of situation you would need to do some troubleshooting to find a way to see the error so that you can test the items in your workspaces to see what relates to the problem.
Comment
-
Reporting continuing NT v8117 freezing, once yesterday and today at random times. Yesterday, as is typical, the NT process had to be manually ended in Task Manager. Today, the Control Center was still responsive so it could close NT. The control center is only responsive to close on the first click attempt. If clicking on anything else in control center before close, the Control Center freezes and Task Manager is required to close. One commonality - the charts that first freeze and become unresponsive have the chart trader visible, and sometimes also a chart abutting will freeze as well. Usually it is during a chart scroll action that the chart freezes, but sometimes it is unattended, with no user input. The other charts of the same symbol remain responsive to mouse control, but all data updating for that symbol stops as of the moment of first chart freeze. Charts of other symbols continue to operate normally with data updating, and can be selected by tab. In the process of closing NT out of this unresponsive state, the usual "Unhandled exception: Write lock may not be acquired with read lock held." error window will popup.
Just reporting this as a continuing issue so NT development staff is aware of it. There are no entries for these events in log or trace files, so no indications for troubleshooting. I'm going to try to roll back to the last 8.0 version, which with the same workspace did not have this freezing issue. I just can't deal with the threat of a NT freeze at any moment while trying to work. This is an 8.1 problem. Although I am a longtime NT user, my opinion of NT continues to decline for many reasons commonly shared with other users.
Comment
-
Hello Lancer,
We can only inform development of these type of items if we have a way to reproduce the problem so that we can make a bug report. Continuing to update this post without some kind of detail on what may be causing the issue will not help and I would not be able to relay any information to development. As mentioned you would need to troubleshoot to see what relates to the problem to further this issue.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
139 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment