アプリケーション/プロセスは、既にアンロードされた ws2_32.dll を参照し、異常終了する場合があります。

<Enlish follows Japanese>

 

こんにちは。日本マイクロソフトの徐です。

 

今回は、Windows 7 環境で動作するアプリケーション/プロセスが、既にアンロードされた ws2_32.dll を参照し、異常終了する場合がある問題についてご紹介します。

 

現象について

+++++++++++

Windows 7 環境で動作するアプリケーション/プロセスが、既にアンロードされた ws2_32.dll を参照し、異常終了する場合があります。

 

発生原因について

+++++++++++++

アプリケーション/プロセスにおいて、ロードする DLL モジュールの初期化処理 (DllMain 関数) の延長上で、API WSAStartup を呼び出す実装が含まれる場合、本現象が発生する可能性があります。
DllMain 関数からAPI WSAStartup を呼び出す制限事項の詳細につきましては、以下技術情報をご参照ください。

WSAStartup function
https://msdn.microsoft.com/en-us/library/windows/desktop/ms742213(v=vs.85).aspx

The WSAStartup function typically leads to protocol-specific helper DLLs being loaded. As a result, the WSAStartup function should not be called from the DllMain function in a application DLL. This can potentially cause deadlocks. For more information, please see the DLL Main Function

https://go.microsoft.com/fwlink/p/?linkid=109533

 

本事象は、DLLモジュールのDllMain 関数の実装による問題ですが、CEIP機能が動作することにより問題が顕在化します。

 

 

解決方法について

++++++++++++++++

恒久的な解決策としては、DllMain 関数の処理中にAPI WSAStartup を呼び出す DLL モジュールの製造元にお問い合わせください。

 

DLL モジュールの製造元から恒久的な解決策を入手するまで、一時的な回避方法としては、カスタマー エクスペリエンス向上プログラム (Customer Experience Improvement Program, 以降 “CEIP” と表記) の無効化を行うことで、本現象を回避できる可能性があります。

 

CEIP を無効化するには、以下のレジストリ値を設定します。

レジストリキー:HKLM\Software\Microsoft\SQMClient\Windows\CEIPEnable
値:0(無効)
https://msdn.microsoft.com/en-us/library/dd405474(VS.85).aspx

 

留意事項1.
グループポリシーにて無条件でCEIP機能を有効にしている環境での回避方法について、補足情報3をご参照ください。

 

留意事項2.
グループポリシー オブジェクトを利用してCEIP機能を有効にしているドメイン環境での回避方法について、以下弊社技術情報の手順6に記述したレジストリキーCEIPEnableの設定を1から0に変更してください。

 

Windows フィードバック転送の展開
- グループ ポリシー オブジェクトを作成して、CEIP を展開するには
https://technet.microsoft.com/ja-jp/library/jj129704.aspx

 

 

補足情報について

++++++++++++++++

補足情報1:本現象が発生する条件(DllMain の実装問題が顕在化する条件) について

本現象が発生する条件は、以下 2 つの CEIP に関わるレジストリキーの値が共に 1 に設定される場合です。

HKLM\Software\Microsoft\SQMClient\Windows\CEIPEnable
HKLM\SOFTWARE\Microsoft\SQMClient\Windows\CEIPSampledIn

レジストリキー CEIPEnable は、CEIP 機能が有効するかどうかを制御するためのレジストリキーです。
CEIPEnable の値が 1 に設定された場合、CEIP 機能は有効となります。
EIPEnable の値が 0 に設定された場合、CEIP 機能は無効となります。

レジストリキー CEIPSampledIn は、CEIP 機能を有効に設定した場合に、対象マシンから収集されたCEIP 情報をマイクロソフトへ送付するかどうかを制御するためのレジストリキーです。
CEIPSampledIn の値が 1 に設定された場合、収集されたCEIP に関わる情報をマイクロソフトへ送付します。
CEIPSampledIn の値が 0 に設定された場合、CEIP に関わる情報をマイクロソフトへ送付しません。

補足資料2:レジストリキー CEIPSampledIn の設定、及びその必要性について

wsqmcons.exe と呼ばれるアプリケーションは、Windows 7 インストール時にタスク スケジューラに登録され、19 時間間隔で実行されます。
本アプリケーションの実行時に、レジストリキー CEIPSampledIn が追加/変更される可能性があります。

タスク スケジューラ ライブラリ -> Microsoft -> Windows -> Customer Experience Improvement Program -> Consolidator

レジストリキー CEIPSampledIn の値は、基本的に以下の三つのレジストリキーにより決まります。
そのうち、レジストリキー RacSampleNumber は、8 バイトの乱数を基に作成されます。

HKLM\Software\Microsoft\SQMClient\Windows\CEIPSamplingRangeLow (既定値は 1)

HKLM\Software\Microsoft\SQMClient\Windows\CEIPSamplingRangeHigh (既定値は 10,000,000)

HKLM\Software\Microsoft\Reliability Analysis\RAC\RacSampleNumber (最大値は 0xFFFFFFFF = 4,294,967,295 までの乱数)

上記 3 つのレジストリキーに対して、以下の条件を満たす場合には、CEIPSampledIn の値が 1 に設定されます。
条件を満たさない場合には、CEIPSampledIn の値が 0 に設定されます。

CEIPSamplingRangeLow の値 <= RacSampleNumber の値 <= CEIPSamplingRangeHigh の値

上記のような実装を行う理由としては、CEIP 機能を有効に設定するマシンが膨大な数になる可能性があるためです。
そのため、CEIP 情報のマイクロソフトへの送付を、サンプリングするように実装されます。

すなわち、上記の条件を満たした場合(RacSampleNumber の値は 1 ~ 10,000,000 の範囲内である場合)のみ、該当マシンは CEIP のサンプリングの対象となり、CEIPSampledIn が 1 に設定され、CEIP 情報をマイクロソフトへ送付します。

RacSampleNumber の値が 1 ~ 10,000,000 の範囲外の場合には、該当マシンは CEIP のサンプリングの対象外となり、CEIPSampledIn が 0 に設定され、CEIP 情報をマイクロソフトへ送付しません。

 

 

補足情報3:グループポリシーを使用した際の CEIP の無効化について

場所:ローカル コンピューター ポリシーの「コンピューターの構成」-> 「管理用テンプレート」-> 「システム」-> 「インターネット通信の管理」-> 「インターネット通信の設定」
ポリシー名:「Windows カスタマー エクスペリエンス向上プログラムをオフにする」

上記グループポリシーを無効に設定した場合、すべてのユーザが無条件で Windows カスタマーエクスペリエンス向上プログラムに参加する設定に変更され、 CEIP の機能が有効となります。
そのため、このグループポリシーが無効に設定した環境において、レジストリキー CEIPEnable にて CEIP 機能の無効化を行う場合、該当グループポリシーを有効または未構成に設定変更する必要があります。

 

本現象に関する日本語技術情報は、以下KB2979267をご参照ください。

 

アプリケーション/プロセスは、既にアンロードされた ws2_32.dll を参照し、異常終了する場合があります。

https://support2.microsoft.com/kb/2979267/ja

 

カスタマ エクスペリエンス向上プログラム(CEIP)の詳細及びマイクロソフトへ送付されるCEIPレポートに含まれる情報の詳細につきましては、以下技術情報をご参照ください。

Microsoft カスタマ エクスペリエンス向上プログラム
https://www.microsoft.com/products/ceip/JA-JP/default.mspx

Microsoft® カスタマ エクスペリエンス向上プログラムのプライバシーに関する声明
https://www.microsoft.com/products/ceip/JA-JP/privacypolicy.mspx

 


 

SYMPTOMS

--------------------

Application/Process crashes when referencing unloaded ws2_32.dll in Windows 7.

 

CAUSE

--------------------

Application/Process crashes when API WSAStartup is called from initializing process (DllMain function) in an application DLL.

For the limitations of calling API WSAStartup by DllMain function, visit the following Microsoft website:

 

WSAStartup function

https://msdn.microsoft.com/en-us/library/windows/desktop/ms742213(v=vs.85).aspx

 

The WSAStartup function typically leads to protocol-specific helper DLLs being loaded. As a result, the WSAStartup function should not be called from the DllMain function in a application DLL. This can potentially cause deadlocks. For more information, please see the DLL Main Function(https://go.microsoft.com/fwlink/p/?linkid=109533).

 

The root cause is the way of an implementation of DllMain function in an application DLL. However, this issue only occurs when CEIP is enabled.

 

RESOLUTION

--------------------

To resolve this issue permanently, please contact the application vendor of an application DLL calling the DllMain function.

However, you may disable Customer Experience Improvement Program (CEIP) by setting the following registry key as a temporary workaround before you get the permanent solution from application vender.

 

KEY:HKLM\Software\Microsoft\SQMClient\Windows\CEIPEnable

VALUE:0(Disabled)

https://msdn.microsoft.com/en-us/library/dd405474(VS.85).aspx

 

Note:
1. Please refer “Additional Information 3” below for detail information if the Group Policy “Turn off windows Customer Experience Improvement Program” is disabled on your system.

 

2. Please change registry setting CEIPEnable described in step 6 below from 1 to 0 to disable CEIP and workaround the problem if you’re using Group Policy Object to enable CEIP on your domain environment.

 

Participate in the Customer Experience Improvement Program
- To create a group policy object to deploy the CEIP
https://technet.microsoft.com/en-us/library/jj129704.aspx
 

 

ADDIONAL INFORMATION

--------------------------------

Additional Information 1: The conditions of the issue occurs.

 

This issue occurs when both of the following registry keys related to CEIP are set to 1.

 

HKLM\Software\Microsoft\SQMClient\Windows\CEIPEnable

HKLM\SOFTWARE\Microsoft\SQMClient\Windows\CEIPSampledIn

 

CEIPEnable key is to enable or disable CEIP.

CEIP is enabled when CEIPEnable key is set to 1.

CEIP is disabled when CEIPEnable key is set to 0.

 

CEIPSampledIn key is to decide to send CEIP information to Microsoft.

CEIP information is sent when CEIPSampledIn is set to 1.

CEIP information is not sent when CEIPSampledIn is set to 1.

 

 

Additional Information 2: CEIPSampledIn key setting and the needs.

 

wsqmcons.exe is run every 19 hours by task scheduler in Windows 7 by default.

When wsqmcons.exe is run, CEIPSampledIn is possibly changed or added.

 

       Task Scheduler Library -> Microsoft -> Windows -> Customer Experience Improvement Program -> Consolidator

 

The value of CEIPSampledIn is basically decided by the following three registry keys.

RacSampleNumber key is created based on a 8 bytes random number.

 

HKLM\Software\Microsoft\SQMClient\Windows\CEIPSamplingRangeLow (Default value is 1)

HKLM\Software\Microsoft\SQMClient\Windows\CEIPSamplingRangeHigh (Default value is 10,000,000)

HKLM\Software\Microsoft\Reliability Analysis\RAC\RacSampleNumber (Max value is a random number up to 0xFFFFFFFF = 4,294,967,295)

 

CEIPSampledIn is set to 1 when the following condition is met or else CEIPSampledIn is set to 0.

       The value of CEIPSamplingRangeLow <= The value of RacSampleNumber <= The value of CEIPSamplingRangeHigh

 

The systems enabled CEIP may become huge amount. Therefore, CEIP infomation is sampled by the above implementation. More specifically, only when the above condition is met (RacSampleNumber is between 1 and 10,000,000), the system's CEIP becomes a sampling target.

Therefore CEIPSampledIn is set to 1 and CEIP infomation is sent to Microsoft. When RacSampleNumber is not between 1 and 10,000,000 the system's CEIP does not become a sampling target and CEIP information is not sent to Microsoft.

 

Additional Information 3: Group Policy “Turn off windows Customer Experience Improvement Program”

 

Location: Computer Configuration -> Administrative Templates -> System -> Internet Communication Management -> Internet Communication settings
Policy Name: Turn off windows Customer Experience Improvement Program

 

If you disable this policy setting, all users are opted into the Windows customer Experience Improvement Program unconditionally.
If you need to use registry setting CEIPEnable to disable CEIP on a system with this policy setting disabled, you need to change the policy setting to enable or not configure.
 

 

For the information of Customer Experience Improvement Program (CEIP), visit the following Microsoft website:

 

Microsoft Customer Experience Improvement Program https://www.microsoft.com/products/ceip/en-us/default.mspx

 

Privacy Statement for the Microsoft® Customer Experience Improvement Program https://www.microsoft.com/products/ceip/en-us/privacypolicy.mspx