Solved

ADO bug in VC++ 6 SP5 + Processor Pack

Posted on 2001-08-15
11
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

730 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