ADO bug in VC++ 6 SP5 + Processor Pack

I have recently installed both SP5 and the Processor Pack to visual C++ 6 and I am having the following problem. When an exception occurs inside a try catch block inside a function that calls ado methods the function crashes (in the debug build) on return. The following code runs fine when compiled with an earlier service pack and no processor pack, but with SP5 + Processor Pack it crashes during the return from the test function. Also if I compile it on a pc with an eariler sp, it will debug and run fine on a machine with the latest sp (as long as you don't try to compile!).

The following code has been reduced to the smallest part that I could get it to crash. I compiled it as a Win32 console application and did not change any of the default values. In SP5 + processor pack an access violation occurs when test() returns. This was tested on win2k. I compiled and tested it in debug build only.

#include "stdafx.h"

// You must change this to match your path
#import "D:\program files\common files\system\ado\msado15.dll" \
         no_namespace \
         rename( "EOF", "adoEOF" )

void test()
{
   _RecordsetPtr pRst = NULL;
   try
   {
      throw "a";

      pRst->Open(_variant_t(), _variant_t(),adOpenStatic ,
         adLockReadOnly, adCmdText);
   }
   catch (...)
   {

   }
}

int main(int argc, char* argv[])
{
   test();
   return 0;
}



My question is 1) Has anyone seen this problem? 2) am I doing something wrong?
LVL 1
jdrescherAsked:
Who is Participating?
 
NetminderConnect With a Mentor Commented:
Per recommendation, points refunded and question closed by
Netminder
Community Support Moderator
Experts Exchange
0
 
DanRollinsCommented:
One of the object destructors could be the culprit.  Breakpoint and open the ASM view and single-step to see where it fails.

-- Dan
0
 
jasonclarkeCommented:
> One of the object destructors could be the culprit.  

Unlikely since the only object being destroyed is the null smart pointer,  and you can trace into the source code anyway in a debug build to see what is going on.

Presumably you have the correct version of the Processor pack - there appear to be different versions depending on whether you have SP4 or SP5 installed?

As you say, the code appears to work correctly, and looks OK to me, without the processor pack, so it sounds a lot like some sort of compiler error.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
agriggsCommented:
I tried it and received same error.  I have same config:  Win 2000, VC++ SP5 + PP

Access violation received on last closing brace of test()
0
 
DanRollinsCommented:
>> Unlikely since the only object being destroyed is the null smart pointer,  

It seems to me that at least two _variant_t objects are constructed.

-- Dan
0
 
jasonclarkeCommented:
> It seems to me that at least two _variant_t,
> objects are constructed.

no, look again, throw "a" takes place before the variant_t constructors are called (i.e. the open statement would appear to be redundant).

0
 
jdrescherAuthor Commented:
If you take the open statement out of the code it works like it should. I've had someone else test this problem and they beleive that the processor pack for sp5 is the culprit.
0
 
DanRollinsCommented:
There is a ctor called for pRst, but it does nothing except verify that it is NULL.  Also a dtor is called for pRst at the end of the fn.  It calls _Release() which (in the debug version I examined) overrites some data with 0xcc.  There are several calls to check the stack.

Interestingly, after the throw line..., the compiler stops emitting any code until the closing } at the end of the try { block.

So it seems unlikely that anything in the pRst->Open() call is causing the problem.  The best candidate seems to be the call to _CxxThrowException which could be related to the processor pack or something strange happening in the dtor of pRst.  

Alas, none of this solves your problem.  I suggest (re-suggest) single-stepping through the dissasembly at the end of the fn to see where the error occurs.  Does the same error occur in debug and release versions of the compile?  Does the problem occur if stack checking is turned off?

-- Dan
0
 
jdrescherAuthor Commented:
Thanks. I think the Open causes the problem by using exceptions from COM code. I'm a COM beginner so I don't know the details of how a COM object throws an exception. But I suspect that this is the problem, because the code runs fine without the call to open. I know there is no code for the open because this code will never execute but there should be some code for the exception handling. I've found the problem also occurs with sp4 and the processor pack for sp4. Also, I shortened the example to the minimum code that I could get it to crash. In my project I first saw the crash when the Open statement was causing an exception because I did not have correct path the access database file.


I need to use the processor pack because my code has some inline assembly code to speed up my memory access times and mmx, simd and 3dnow to improve the speed of my image processing algorithms. So I guess my best bet is to compile the DB code in a seperate library and link it to the rest of my code.
0
 
griesshCommented:
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and PAQ at zero points since nobody had an answer for you.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
jdrescherAuthor Commented:
Please delete this question. It has comments that were helpful, but no one comment was able to solve my problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.