Solved

ADO bug in VC++ 6 SP5 + Processor Pack

Posted on 2001-08-15
11
333 Views
Last Modified: 2012-06-27
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?
0
Comment
Question by:jdrescher
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6391628
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
 
LVL 9

Expert Comment

by:jasonclarke
ID: 6391856
> 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
 
LVL 2

Expert Comment

by:agriggs
ID: 6393474
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 6395324
>> 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
 
LVL 9

Expert Comment

by:jasonclarke
ID: 6396198
> 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:jdrescher
ID: 6406617
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 6408061
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
 
LVL 1

Author Comment

by:jdrescher
ID: 6410680
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
 
LVL 11

Expert Comment

by:griessh
ID: 6857321
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
 
LVL 1

Author Comment

by:jdrescher
ID: 6862976
Please delete this question. It has comments that were helpful, but no one comment was able to solve my problem.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 6884213
Per recommendation, points refunded and question closed by
Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now