WMI Automation Interfaces May Cause Unpredictable Program Shutdowns and Data Loss (292766)



The information in this article applies to:

  • Microsoft Windows 2000 Server SP1
  • Microsoft Windows 2000 Advanced Server SP1
  • Microsoft Windows 2000 Professional SP1

This article was previously published under Q292766

SYMPTOMS

When you run programs that use the asynchronous Windows Management Instrumentation (WMI) automation interfaces, the programs may sporadically and unpredictably stop responding or shut down, possibly causing data loss.

RESOLUTION

To resolve this problem, obtain the latest service pack for Windows 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

260910 How to Obtain the Latest Windows 2000 Service Pack

STATUS

Microsoft has confirmed that this is a problem in Microsoft Windows 2000.

This problem was first corrected in Windows 2000 Service Pack 2.

MORE INFORMATION

Any program that uses asynchronous WMI automation interfaces may be subject to unpredictable behavior due to various timing issues. This behavior may not be identified during development of a program because nested events rarely occur. Though the behavior is not seen on most systems, CPU speed, network speed, system load, and external variables can provoke it and lead to unexpected program termination or to data corruption.

As an example, a JScript garbage collection can cause events to fire, producing an unrecoverable crash in JScript and causing all further script code to stop executing. A later version of JScript (later than Windows 2000) suppresses the sudden stops and shutdowns, but WMI automation still fires events at inappropriate times. In particular, an event can be fired at random times while another event is being processed, easily leading to data corruption in the event handlers.

For example, consider the following JScript:
function Sink::OnObjectReady(obj, ...) {
  sz = obj.Name;
  AddLineToOutput(sz);
}
				
The intent of the function is to add a string to an output display as objects are returned asynchronously through the OnObjectReady event. Through an effect of JScript garbage collection, the WMI automation interfaces may fire a nested event between the first and second lines of the function. The result is that the nested function overwrites the contents of the variable sz in the middle of the un-nested function. This causes the output to display the nested event twice, and the information about the un-nested event is lost.

The symptoms of the bug are unpredictable because they depend on the timing of garbage collection and on the speed at which asynchronous operations complete. In real-world programs, this bug is the source of problems that show up infrequently, only once in 40 hours of use or in many thousands of repeated successful operations.

Modification Type:MajorLast Reviewed:11/19/2003
Keywords:kbbug kbfix kbWin2000PreSP2Fix KB292766