Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Exception causes access violation

Thread Tools

Exception causes access violation

Toon Huysmans
Posts: n/a

I have a mind boggling error in VC++ .NET.

An exception THException is being thrown, but it seems to cause an
accessviolation, but the code is so simple that I cant figure out where the
av comes from.

MyMesh:oint cog()
if (fCount != 0)
return fCoG/fCount;
throw THException("There were no vertices to average...");
<--- this gets thrown

class THException
THException(string msg){fMsg = msg;}
string getMessage(){return fMsg;}
string fMsg;

catch(THException e)
cerr << "EXCEPTION:" << e.getMessage() << endl;
cerr << "EXCEPTION:" << "Unknown Exception caught..." << endl;

First-chance exception at 0x77e73887 in SphericalParameterization.exe:
Microsoft C++ exception: THException @ 0x0012f9d8.
First-chance exception at 0x004f1bbc in SphericalParameterization.exe:
0xC0000005: Access violation reading location 0xcdcdcddd.

Reply With Quote
Ron Natalie
Posts: n/a

"Toon Huysmans" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi,
> I have a mind boggling error in VC++ .NET.

Try this in It looks fine from a C++ point of
view (provided all those spurious copies of string don't throw).

CDCDCDCD is the debug mode "fill" pattern for uninitialized memory.
Are you sure the compile options you have specified allow exceptions?
I don't know about .NET, but VC6 you had to specifically enable exception
handling (and even then there were some bugs in it).

> class THException
> {
> public:
> THException(string msg){fMsg = msg;}

How aboiut
THException(const string& msg) : fMsg(msg) { }

> catch(THException e)

If you ever derive from THException, would be better to catch by reference here.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Does anyone know what this means? CAVIStreamSynth: System exception -Access Violation at 0x62622371, reading from 0x62c8d334 CS Student C Programming 3 06-17-2011 12:26 AM
WindowsError: exception: access violation writing 0x00000000 Sparky Python 3 08-04-2009 05:23 PM
Statically linked library causes segmentation violation upon C++ throw C++ 2 06-09-2006 10:51 PM
exception : 0xC0000005: Access Violation batista C++ 4 11-08-2005 03:25 AM
RegExp Replace Method causes Access Violation Alex ASP General 7 11-17-2003 10:37 AM