【发布时间】:2014-08-03 10:05:44
【问题描述】:
更新 1:我包含了所有线程的堆栈跟踪,而不仅仅是主线程的 - 我认为这已经足够了。
更新 2:我重新打开了这个问题,因为即使应用了我自己问题中说明的更改,我今天仍然收到相同的错误报告...
更新 3:似乎错误发生在线程终止时,错误发生时发送的线程消息是COmniTaskMsg_Terminated。现在很奇怪 - 我已经用线程安全队列替换了程序中几乎所有对Task.Comm.Send() 的调用,所以我很确定通过Task.Comm 的线程消息数量非常少,远远少于这可能会填满 Windows 消息队列...
我在 Delphi XE4 中使用 OmniThreadLibrary-3.03a(刚刚升级到最新的 svn,我会看到...),并从最终用户那里得到一个错误报告,错误消息和线程的堆栈跟踪这个问题放在最后。
实际上,我已经减少了发生此错误的可能性,方法是将调用Task.Comm.Send() 替换为线程安全队列,后台线程使用该队列将日志发送到主线程。现在不知道在哪里看,最有可能的地方就在这里(但在这个代码块内没有Task.Comm.Send() 调用...):
//at this point, we are already in a thread other than the main thread.
//I've two instances of the very same thread running when the program runs.
myTasks := Parallel.ParallelTask.NumTasks(aTaskCount);// aTaskCount = 5
myTasks.Execute(
//the following anonymous method will be executed in sub-threads and will have
//multiple instances determined by the aTaskCount param.
procedure (const aSubTask: IOmniTask)
begin
//note: this code block runs in multiple sub-threads in parallel.
//aUidList can have tens of thousands (or even more) of item.
while aUidList.Take(uid) and (not Self.task.CancellationToken.IsSignalled) do
begin
ThreadedDoSomething();
end;
end
);//END sub-thread
堆栈跟踪:
process id : $2f9c
allocated memory : 181.30 MB
largest free block : 1019.73 MB
executable : MyProgram.exe
exec. date/time : 2014-08-02 21:12
version : 1.0.7.256
compiled with : Delphi XE4
madExcept version : 4.0.9
callstack crc : $8b5fc164, $b1225a03, $7caf0d48
exception number : 1
exception class : EOSError
exception message : System Error. Code: 1816. Not enough quota is available to process this command.
thread $1160 (TOmniThread): <priority:-15>
0045c3de MyProgram.exe System.SysUtils RaiseLastOSError
0045c35b MyProgram.exe System.SysUtils RaiseLastOSError
0045c40f MyProgram.exe System.SysUtils Win32Check
0075b387 MyProgram.exe OtlContainerObserver 252 TOmniContainerWindowsMessageObserverImpl.Send
0076debb MyProgram.exe OtlTaskControl 1378 TOmniTask.InternalExecute
0076db6a MyProgram.exe OtlTaskControl 1274 TOmniTask.Execute
0077423c MyProgram.exe OtlTaskControl 3091 TOmniThread.Execute
004ab243 MyProgram.exe madExcept HookedTThreadExecute
0053c596 MyProgram.exe System.Classes ThreadProc
0040a5b4 MyProgram.exe System 150 ThreadWrapper
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by main thread ($1408) at:
007741a1 MyProgram.exe OtlTaskControl 3080 TOmniThread.Create
main thread ($1408):
0090f52d MyProgram.exe VirtualTrees 33601 TBaseVirtualTree.SortTree
00906fd1 MyProgram.exe VirtualTrees 28348 TBaseVirtualTree.EndUpdate
008f3563 MyProgram.exe VirtualTrees 17031 TBaseVirtualTree.SetRootNodeCount
00b66d99 MyProgram.exe BackupControlFrame 219 TfraBackupControl.AddLog
00b66be2 MyProgram.exe BackupControlFrame 179 TfraBackupControl.AddLog
00b69595 MyProgram.exe BackupControlFrame 844 TfraBackupControl.TimerReadLogTimer
005f430b MyProgram.exe Vcl.ExtCtrls TTimer.Timer
005f41ef MyProgram.exe Vcl.ExtCtrls TTimer.WndProc
0053fca4 MyProgram.exe System.Classes StdWndProc
76777885 USER32.dll DispatchMessageW
00656b87 MyProgram.exe Vcl.Forms TApplication.ProcessMessage
00656bca MyProgram.exe Vcl.Forms TApplication.HandleMessage
00656f05 MyProgram.exe Vcl.Forms TApplication.Run
00b83f34 MyProgram.exe MyProgram 130 initialization
75223368 kernel32.dll BaseThreadInitThunk
thread $22a4:
771d0156 ntdll.dll NtWaitForMultipleObjects
75223368 kernel32.dll BaseThreadInitThunk
thread $1604:
771d0156 ntdll.dll NtWaitForMultipleObjects
761215e3 KERNELBASE.dll WaitForMultipleObjectsEx
752219f7 kernel32.dll WaitForMultipleObjectsEx
76780864 USER32.dll MsgWaitForMultipleObjectsEx
76780b64 USER32.dll MsgWaitForMultipleObjects
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by main thread ($1408) at:
738778e1 gdiplus.dll
thread $3060 (TWorkerThread):
771cf8ca ntdll.dll NtWaitForSingleObject
76121497 KERNELBASE.dll WaitForSingleObjectEx
7522118f kernel32.dll WaitForSingleObjectEx
75221143 kernel32.dll WaitForSingleObject
008e2dbe MyProgram.exe VirtualTrees 6364 TWorkerThread.Execute
004ab243 MyProgram.exe madExcept HookedTThreadExecute
0053c596 MyProgram.exe System.Classes ThreadProc
0040a5b4 MyProgram.exe System 150 ThreadWrapper
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by main thread ($1408) at:
008e2cda MyProgram.exe VirtualTrees 6312 TWorkerThread.Create
thread $22c0:
771d1f3f ntdll.dll NtWaitForWorkViaWorkerFactory
75223368 kernel32.dll BaseThreadInitThunk
thread $33d0:
771cf8ca ntdll.dll NtWaitForSingleObject
76121497 KERNELBASE.dll WaitForSingleObjectEx
7522118f kernel32.dll WaitForSingleObjectEx
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by thread $31fc at:
7327325b rasman.dll
thread $2dc4:
771cf8ca ntdll.dll NtWaitForSingleObject
764b2f7b WS2_32.dll WahReferenceContextByHandle
764b6a25 WS2_32.dll select
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by main thread ($1408) at:
75349791 WININET.dll
thread $2148:
771d1f3f ntdll.dll NtWaitForWorkViaWorkerFactory
75223368 kernel32.dll BaseThreadInitThunk
thread $2258 (TOmniThread): <priority:-15>
771d0156 ntdll.dll NtWaitForMultipleObjects
761215e3 KERNELBASE.dll WaitForMultipleObjectsEx
752219f7 kernel32.dll WaitForMultipleObjectsEx
76780864 USER32.dll MsgWaitForMultipleObjectsEx
00771942 MyProgram.exe OtlTaskControl 2379 TOmniTaskExecutor.WaitForEvent
00770ddc MyProgram.exe OtlTaskControl 2148 TOmniTaskExecutor.MainMessageLoop
0076fb2e MyProgram.exe OtlTaskControl 1849 TOmniTaskExecutor.DispatchMessages
0076e7d9 MyProgram.exe OtlTaskControl 1636 TOmniTaskExecutor.Asy_Execute
0076dd59 MyProgram.exe OtlTaskControl 1354 TOmniTask.InternalExecute
0076db6a MyProgram.exe OtlTaskControl 1274 TOmniTask.Execute
0077423c MyProgram.exe OtlTaskControl 3091 TOmniThread.Execute
0040a5b4 MyProgram.exe System 150 ThreadWrapper
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by thread $1160 (TOmniThread) at:
007741a1 MyProgram.exe OtlTaskControl 3080 TOmniThread.Create
thread $618 (TOTPWorkerThread): <priority:-15>
771d0156 ntdll.dll NtWaitForMultipleObjects
761215e3 KERNELBASE.dll WaitForMultipleObjectsEx
752219f7 kernel32.dll WaitForMultipleObjectsEx
752241d3 kernel32.dll WaitForMultipleObjects
0074b749 MyProgram.exe DSiWin32 1949 DSiWaitForTwoObjects
007782ca MyProgram.exe OtlComm 478 TOmniCommunicationEndpoint.ReceiveWait
007639cc MyProgram.exe OtlThreadPool 625 TOTPWorkerThread.Execute
004ab243 MyProgram.exe madExcept HookedTThreadExecute
0053c596 MyProgram.exe System.Classes ThreadProc
0040a5b4 MyProgram.exe System 150 ThreadWrapper
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by thread $2258 (TOmniThread) at:
0076348c MyProgram.exe OtlThreadPool 537 TOTPWorkerThread.Create
thread $5f0 (TOTPWorkerThread): <priority:-15>
771d0156 ntdll.dll NtWaitForMultipleObjects
761215e3 KERNELBASE.dll WaitForMultipleObjectsEx
752219f7 kernel32.dll WaitForMultipleObjectsEx
752241d3 kernel32.dll WaitForMultipleObjects
0074b749 MyProgram.exe DSiWin32 1949 DSiWaitForTwoObjects
007782ca MyProgram.exe OtlComm 478 TOmniCommunicationEndpoint.ReceiveWait
007639cc MyProgram.exe OtlThreadPool 625 TOTPWorkerThread.Execute
004ab243 MyProgram.exe madExcept HookedTThreadExecute
0053c596 MyProgram.exe System.Classes ThreadProc
0040a5b4 MyProgram.exe System 150 ThreadWrapper
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by thread $2258 (TOmniThread) at:
0076348c MyProgram.exe OtlThreadPool 537 TOTPWorkerThread.Create
thread $2a84 (TOTPWorkerThread): <priority:-15>
771d0156 ntdll.dll NtWaitForMultipleObjects
761215e3 KERNELBASE.dll WaitForMultipleObjectsEx
752219f7 kernel32.dll WaitForMultipleObjectsEx
752241d3 kernel32.dll WaitForMultipleObjects
0074b749 MyProgram.exe DSiWin32 1949 DSiWaitForTwoObjects
007782ca MyProgram.exe OtlComm 478 TOmniCommunicationEndpoint.ReceiveWait
007639cc MyProgram.exe OtlThreadPool 625 TOTPWorkerThread.Execute
004ab243 MyProgram.exe madExcept HookedTThreadExecute
0053c596 MyProgram.exe System.Classes ThreadProc
0040a5b4 MyProgram.exe System 150 ThreadWrapper
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by thread $2258 (TOmniThread) at:
0076348c MyProgram.exe OtlThreadPool 537 TOTPWorkerThread.Create
thread $1ca0 (TOTPWorkerThread): <priority:-15>
771d0156 ntdll.dll NtWaitForMultipleObjects
761215e3 KERNELBASE.dll WaitForMultipleObjectsEx
752219f7 kernel32.dll WaitForMultipleObjectsEx
752241d3 kernel32.dll WaitForMultipleObjects
0074b749 MyProgram.exe DSiWin32 1949 DSiWaitForTwoObjects
007782ca MyProgram.exe OtlComm 478 TOmniCommunicationEndpoint.ReceiveWait
007639cc MyProgram.exe OtlThreadPool 625 TOTPWorkerThread.Execute
004ab243 MyProgram.exe madExcept HookedTThreadExecute
0053c596 MyProgram.exe System.Classes ThreadProc
0040a5b4 MyProgram.exe System 150 ThreadWrapper
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by thread $2258 (TOmniThread) at:
0076348c MyProgram.exe OtlThreadPool 537 TOTPWorkerThread.Create
thread $3248 (TOTPWorkerThread): <priority:-15>
771d0156 ntdll.dll NtWaitForMultipleObjects
761215e3 KERNELBASE.dll WaitForMultipleObjectsEx
752219f7 kernel32.dll WaitForMultipleObjectsEx
752241d3 kernel32.dll WaitForMultipleObjects
0074b749 MyProgram.exe DSiWin32 1949 DSiWaitForTwoObjects
007782ca MyProgram.exe OtlComm 478 TOmniCommunicationEndpoint.ReceiveWait
007639cc MyProgram.exe OtlThreadPool 625 TOTPWorkerThread.Execute
004ab243 MyProgram.exe madExcept HookedTThreadExecute
0053c596 MyProgram.exe System.Classes ThreadProc
0040a5b4 MyProgram.exe System 150 ThreadWrapper
004ab129 MyProgram.exe madExcept CallThreadProcSafe
004ab18e MyProgram.exe madExcept ThreadExceptFrame
75223368 kernel32.dll BaseThreadInitThunk
>> created by thread $2258 (TOmniThread) at:
0076348c MyProgram.exe OtlThreadPool 537 TOTPWorkerThread.Create
thread $11c8:
771d1f3f ntdll.dll NtWaitForWorkViaWorkerFactory
75223368 kernel32.dll BaseThreadInitThunk
参考this answer of another question,好像是OTL用作通信通道的Windows消息队列满了。
【问题讨论】:
-
如果您仍在寻求帮助,我将回到我之前所说的内容,并强调您确实需要向我们展示您正在使用的可以重现问题的代码。理想情况下,您会尝试制作一个可以重现该问题的 SSCCE。 sscce.org
-
@J...,代码很复杂,并且与其他代码和特定数据相结合,我目前无法生成另一个示例代码。 PS,我刚刚添加了更新3...
-
好吧,再一次,如果没有看到代码,很难说太多。您的下一个任务应该是复制您的源代码并开始消除代码,直到问题消失。清空方法,添加调试日志,并尽可能减少代码,直到你有一些简短的东西可以重现问题或直到问题消失。在前一种情况下,您将有更好的机会在这里获得帮助,在后一种情况下,有问题的代码应该为您识别问题。无论哪种方式,它都应该让您更接近解决方案。
标签: delphi delphi-xe4 omnithreadlibrary