世界が認める天才プログラマー 山下遼太氏の
超高機能5ちゃんねるブラウザー 「Jane Style」 専用スレ (ソフトウェア板)
■ Jane Style公式HP (DL先)
http://janesoft.net/janestyle/
Jane Style ヘルプ
http://janesoft.net/janestyle/help/index.html
(株)ジェーンHP=http://janesoft.net/
Jane Style wiki=http://ja.wikipedia.org/wiki/Jane
前スレ
Jane Style Part143
https://egg.5ch.net/test/read.cgi/software/1521284142/
探検
Jane Style★144
■ このスレッドは過去ログ倉庫に格納されています
1名無しさん@お腹いっぱい。
2018/04/13(金) 02:27:54.11ID:ug6VcNmJ0285名無しさん@お腹いっぱい。
2018/05/10(木) 22:15:58.51ID:u731Wp890 例のデッドロックと例外0eedfadeの話
ttps://marc.durdin.net/2012/08/locating-delphi-exceptions-in-a-live-session-or-dump-using-windbg/
これを見つけたけど関係あるかよくわからず読まなかったが、隣の記事
https://marc.durdin.net/2012/08/waitforsingleobject-why-you-should-never-use-it/
WaitForSingleObject. Why you should never use it.
モロこの問題じゃない?
COMとかOLEみたいなのが隠れウインドウ(※2)を扱うとメッセージが発生して、
メインスレッドでWaitForSingleObject使ってるとメッセージが詰まっちゃうってことじゃないかな。
Except that WaitForSingleObject and its big brother WaitForMultipleObjects are dangerous.
The basic problem is that these calls can cause deadlocks, if you ever call them from a thread that has its own message loop and windows.
That’s okay, you say, I don’t have any UI except in my main thread.
But any thread that uses COM can have hidden COM helper windows when doing RPC (and see below for more on this).
And other libraries can create their own windows as well, such as the ADO libraries.
So what causes the deadlock? Well, I’ll illustrate with the scenario we ran into.
Some old code (that I wrote, okay, okay) created a thread (we’ll call it BackgroundThread).
BackgroundThread used TThread.Synchronize to periodically update the UI status about a background database process it was running.
It doesn’t really matter what it was doing, but the use of Microsoft’s ADO database library meant that this thread was creating a hidden window,
with the class ADODB.AsyncEventMessenger.
Behind the scenes, a second window was automatically created by Windows once we had the first window in the thread, and this one had the class name IME.
(※2)https://egg.5ch.net/test/read.cgi/software/1521284142/813
ttps://marc.durdin.net/2012/08/locating-delphi-exceptions-in-a-live-session-or-dump-using-windbg/
これを見つけたけど関係あるかよくわからず読まなかったが、隣の記事
https://marc.durdin.net/2012/08/waitforsingleobject-why-you-should-never-use-it/
WaitForSingleObject. Why you should never use it.
モロこの問題じゃない?
COMとかOLEみたいなのが隠れウインドウ(※2)を扱うとメッセージが発生して、
メインスレッドでWaitForSingleObject使ってるとメッセージが詰まっちゃうってことじゃないかな。
Except that WaitForSingleObject and its big brother WaitForMultipleObjects are dangerous.
The basic problem is that these calls can cause deadlocks, if you ever call them from a thread that has its own message loop and windows.
That’s okay, you say, I don’t have any UI except in my main thread.
But any thread that uses COM can have hidden COM helper windows when doing RPC (and see below for more on this).
And other libraries can create their own windows as well, such as the ADO libraries.
So what causes the deadlock? Well, I’ll illustrate with the scenario we ran into.
Some old code (that I wrote, okay, okay) created a thread (we’ll call it BackgroundThread).
BackgroundThread used TThread.Synchronize to periodically update the UI status about a background database process it was running.
It doesn’t really matter what it was doing, but the use of Microsoft’s ADO database library meant that this thread was creating a hidden window,
with the class ADODB.AsyncEventMessenger.
Behind the scenes, a second window was automatically created by Windows once we had the first window in the thread, and this one had the class name IME.
(※2)https://egg.5ch.net/test/read.cgi/software/1521284142/813
286名無しさん@お腹いっぱい。
2018/05/10(木) 22:18:21.43ID:u731Wp890 対処法らしきもの
In any case, to make your own code more robust:
1.Determine, when using synchronisation calls, if there is any chance that windows could be created by your thread,
and if so, use MsgWaitForMultipleObjects and a message loop instead of WaitForSingleObject or WaitForMultipleObjects.
Check the libraries you are using, and if you are using COM, it’s safest to assume that windows will be created.
2.Don’t use the TThread.Synchronize procedure. Recent versions of Delphi include TThread.Queue, which is asynchronous, and so avoids this deadlock.
3.Think carefully about whether a thread is the right solution to the problem.
4.Don’t use the KLF_SETFORPROCESS flag!
Delphiの不具合というより、
いろいろな人がコンポーネントを作るから、
Delphiに蔓延してる病気みたいなものだろう。
だからといって長年?放置していい理由にならないけど。
通信が滞った場合に、メッセージが詰まり、謎例外0eedfadeでソケットのスレッドが終わって、メインスレッドが無限に止まると。
65秒パッチはある意味正解だったようだな≒MsgWaitForMultipleObjects気持ち悪いAPIだけど、
特定WM_〜で動くみたい。
OpenJane〜JaneLovelyソース見る限り、単純にこれに変えても結果は同じかな。
GUIにメッセージ送るやりかた工夫しないとね。
In any case, to make your own code more robust:
1.Determine, when using synchronisation calls, if there is any chance that windows could be created by your thread,
and if so, use MsgWaitForMultipleObjects and a message loop instead of WaitForSingleObject or WaitForMultipleObjects.
Check the libraries you are using, and if you are using COM, it’s safest to assume that windows will be created.
2.Don’t use the TThread.Synchronize procedure. Recent versions of Delphi include TThread.Queue, which is asynchronous, and so avoids this deadlock.
3.Think carefully about whether a thread is the right solution to the problem.
4.Don’t use the KLF_SETFORPROCESS flag!
Delphiの不具合というより、
いろいろな人がコンポーネントを作るから、
Delphiに蔓延してる病気みたいなものだろう。
だからといって長年?放置していい理由にならないけど。
通信が滞った場合に、メッセージが詰まり、謎例外0eedfadeでソケットのスレッドが終わって、メインスレッドが無限に止まると。
65秒パッチはある意味正解だったようだな≒MsgWaitForMultipleObjects気持ち悪いAPIだけど、
特定WM_〜で動くみたい。
OpenJane〜JaneLovelyソース見る限り、単純にこれに変えても結果は同じかな。
GUIにメッセージ送るやりかた工夫しないとね。
■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 中国外務省局長 「ポケットに手を入れていたのは寒いから」 日本との局長級会談で ★3 [お断り★]
- トランプ氏、女性記者に「ブタ、静かに」 エプスタイン元被告めぐる質問さえぎる [1ゲットロボ★]
- 【株価】日経平均、上げ幅一時2000円超 5万円台を回復 [蚤の市★]
- 高市首相「台湾有事」発言引き出した「立憲・岡田克也氏」に聞いた質問の真意「これはマズイ発言だと」少しずらしてみたが焼け石に水 ★2 [ぐれ★]
- トランプ氏「台湾侵攻すれば北京爆撃」“過激予告発言”報道がXで再燃「高市氏の1億倍やばい」 [七波羅探題★]
- 【自民/維新】国会議員の歳費、月5万円アップで調整 月額134万4000円に 維新配慮で次の国政選挙後に引き上げ方針 [Hitzeschleier★]
- 「ネトウヨが中国人以上の価格でホタテを買って食う」こんな簡単なことを前回も今回もできないのは不思議と話題 [158478931]
- インフルエンザにかかりやすい5つの特徴、「血糖値高め」「睡眠不足」「栄養不良」「アレルギーがある」「安倍晋三」 [748563222]
- 【高市感謝】韓国政府「福島第一原発からの16回目の汚染水放出が終わった。モニタリング結果は基準値の1/37と低かった」 冷静な対応 [485983549]
- トランプ「中国が他国産より高値で米国産大豆を大量購入してくれた。中国最高!」 どっかのバカ日本人との差w [271912485]
- 日本人「な、なぜだ?なぜこの件で日本を助けてくれる国が0カ国なんだ!?」。日本人、さすがに気づく [805596214]
- 【高市餅】 もち米不足が深刻。 正月用のお餅は値上げ。 去年より5割以上高騰。 晋さん、もう日本人はお正月にお餅を食べれないよ、、、 [485983549]
