Microsoft KB Archive/277821

From BetaArchive Wiki

Article ID: 277821

Article Last Modified on 1/29/2007



APPLIES TO

  • Microsoft Windows 2000 Service Pack 1
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Service Pack 1



This article was previously published under Q277821

SYMPTOMS

When you migrate a Microsoft Transaction Server (MTS) application to COM+, and you do not call the SetComplete or SetAbort method, an Access Violation may occur, and the application may fail (crash). This problem occurs in COM+ (Windows 2000 Service Pack 1) and not in MTS.

CAUSE

This problem occurs when non-root transactional objects release the object reference to their parent object and do not call SetComplete or SetAbort explicitly at the end of the method.

This problem is caused by a difference in the activation and deactivation mechanisms between COM+ and MTS. In COM+, if the child object does not set the done bit to true (if it does not call the IObjectControl::SetComplete or the IObjectControl::SetAbort method, does not call the IContextState:setCompletion method, or does not use Auto-Completion), the COM+ interception layer deactivates the parent object before the child object. In fact, you do not need to set the done bit, even if it is preferred in most situations.

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

Steps to Reproduce Behavior

  1. Create a dynamic-link library (DLL) with three objects: Root, Parent, and Child. Set the transaction attribute to Requires a transaction.
  2. The client calls CoCreateInstance on the first Root object.
  3. The client calls the Root::RootMethod method.
  4. In Root::RootMethod, use the CreateInstance method of the ObjectContext object to create the Parent object in the context of MTS. Then call the Parent::ParentMethod method.
  5. In the Parent::Activate method, call CCI on Child, or ObjCtx.CreateInstance in MTS, and then call Child::SetOwner(this), or SafeRef(this) in MTS.
  6. In the Child::Activate method, save the reference to Parent in the myOwner member variable.
  7. In Parent::ParentMethod, call the Child::ChildMethod method.
  8. In Child::ChildMethod, return without calling SetAbort or SetComplete.
  9. In the Child::DeActivate method, release its reference to its owner object Parent.
  10. In the Parent::DeActivate method, release its reference to Child.
  11. Call Child::DeActivate.

NOTE: The Access Violation occurs in COM+ because step 10 occurs before step 9.


Additional query words: crash AV

Keywords: kberrmsg kbbug kbfix kbwin2000presp2fix KB277821