Memory Access Violation in Release Mode 
Author Message
 Memory Access Violation in Release Mode

Hi All,

I am building some libraries with VC 6.0. I am getting a Memory Access
Violation error in release mode. The code works fine in Debug mode.
I am allocating some memory and while freeing that memory the error
occurs.But the behavior is strange,if I put the printf statement at the
point where I am getting a crash and put two %d specifiers then the code
works fine. if you remove even one %d from the printf  statement then the
code fails.

Let me share one thing. There are so many type casting in the code. I doubt
the problem may be there. But I do not understand why the code works fine
with debug mode?

If anyone know the answer. Please reply.

Thanks in advance.

Regards,

Atul



Sun, 16 Feb 2003 03:00:00 GMT  
 Memory Access Violation in Release Mode

Quote:

> Hi All,

> I am building some libraries with VC 6.0. I am getting a Memory
> Access Violation error in release mode. The code works fine in Debug
> mode.

Debug mode works differently.  It will zero out memory for you and do
other things to supposedly "help" you write code better.  I don't see
how it helps, because when something is zero in a debug build, but not
zero in a release build (such as a pointer) it may exhibit different
behavior, and crash.  (For example, deleting a zero-pointer is
guarenteed safe, but deleting a non-zero uninitialized pointer is
unsafe.)

You should look through your code for uninitialized values, or
unterminated char strings.

Quote:
> I am allocating some memory and while freeing that memory the error
> occurs.But the behavior is strange,if I put the printf statement at
> the point where I am getting a crash and put two %d specifiers then
> the code works fine.

Obviously the printf is somehow hiding the memory bug.  Because code
APPEARS to work "fine" doesn't mean it does!  You actually should be
thankful that it crashes and angry that the printf "hides" the
problem.  Hidden bugs are much harder to fix.

Quote:
>if you remove even one %d from the printf  statement then the
> code fails.

If your format string and your parameters don't match exactly, you
can't have reliable results.

Quote:
> Let me share one thing. There are so many type casting in the
> code. I doubt the problem may be there. But I do not understand why
> the code works fine with debug mode?

Why do you need so much casting?  Any casts other than
once-in-a-rare-while cast suspicion on a design.  It forfeits an
incredible amount of help that the compiler COULD be giving you in
tracking down problems.

Quote:
> If anyone know the answer. Please reply.

I don't know the answer, but I'd guess it's the debug libraries whose
behavior is different.  Perhaps you can link the release RTL into a
debug build, so you can look at your code in the de{*filter*}, but not use
the "help" of their debug RTL.  (I'm not sure if you can do this, but
if you can, you should.)

--
Chris



Sun, 16 Feb 2003 03:00:00 GMT  
 Memory Access Violation in Release Mode

Atul

I saw your post on at least three news groups. If you
*must* post to more than one group, please cross post.
Don't multipost.  Multiposting means there is a copy
of your post on each group. Cross posting means there
is only one copy that is shared across the groups.
Also, many news readers will only show cross posted
messages once.  So all round crossposting is preferred
to multiposting.  People will be happier with you, and
you will get more and better responses.

However, posting only to the most relevant group, one
singular group, is the most preferred. If you don't get
an answer there, then look further.  People will be the
most happy with you, and you will get the best response.

Anyway, I posted an answer to this on another group.
You'll have to hunt for it if you want it.
--
Dan Evens
Standard disclaimers etc. No spam please.



Sun, 16 Feb 2003 03:00:00 GMT  
 Memory Access Violation in Release Mode


Quote:

> > Hi All,

> > I am building some libraries with VC 6.0. I am getting a Memory
> > Access Violation error in release mode. The code works fine in Debug
> > mode.

In addition to Chris' suggestions, look for any array on
the stack and make sure you are not overflowing it.  The
optimizer will re-arrange the variables on the stack and
it can present a situation where data is benignly overwritten
in debug mode but malignantly in release mode.

marco



Sun, 16 Feb 2003 03:00:00 GMT  
 Memory Access Violation in Release Mode


Fri, 19 Jun 1992 00:00:00 GMT  
 Memory Access Violation in Release Mode
Anyone with a copy of the August 2000 Windows Developer's Journal turn
to page 7.  Look who's there.

Clean up your office, Marco :=)

Joe O'

"Marco Dalla Gasperina" wrote

Quote:

> "Chris Uzdavinis" wrote
> > "Atul Joshi" writes:

> > > Hi All,

> > > I am building some libraries with VC 6.0. I am getting a Memory
> > > Access Violation error in release mode. The code works fine in
Debug
> > > mode.

> In addition to Chris' suggestions, look for any array on
> the stack and make sure you are not overflowing it.  The
> optimizer will re-arrange the variables on the stack and
> it can present a situation where data is benignly overwritten
> in debug mode but malignantly in release mode.

> marco



Sun, 16 Feb 2003 03:00:00 GMT  
 Memory Access Violation in Release Mode
Shhh!

Yes, that's me... my brief forway into the fast paced
world of modelling.  I decided to keep my day job.

marco


Quote:
> Anyone with a copy of the August 2000 Windows Developer's Journal turn
> to page 7.  Look who's there.

> Clean up your office, Marco :=)

> Joe O'



Sun, 16 Feb 2003 03:00:00 GMT  
 Memory Access Violation in Release Mode


Fri, 19 Jun 1992 00:00:00 GMT  
 Memory Access Violation in Release Mode

Quote:


>> Hi All,

>> I am building some libraries with VC 6.0. I am getting a Memory
>> Access Violation error in release mode. The code works fine in Debug
>> mode.

>Debug mode works differently.  It will zero out memory for you and do
>other things to supposedly "help" you write code better.  I don't see
>how it helps, because when something is zero in a debug build, but not
>zero in a release build (such as a pointer) it may exhibit different
>behavior, and crash.  (For example, deleting a zero-pointer is
>guarenteed safe, but deleting a non-zero uninitialized pointer is
>unsafe.)

Debug mode doesn't actively do this, and to my knowledge, it never
has. Note that VC6 adds a new compiler option (/GZ) to set
uninitialized auto variables to certain non-zero values.

- Show quoted text -

Quote:
>You should look through your code for uninitialized values, or
>unterminated char strings.

>> I am allocating some memory and while freeing that memory the error
>> occurs.But the behavior is strange,if I put the printf statement at
>> the point where I am getting a crash and put two %d specifiers then
>> the code works fine.

>Obviously the printf is somehow hiding the memory bug.  Because code
>APPEARS to work "fine" doesn't mean it does!  You actually should be
>thankful that it crashes and angry that the printf "hides" the
>problem.  Hidden bugs are much harder to fix.

>>if you remove even one %d from the printf  statement then the
>> code fails.

>If your format string and your parameters don't match exactly, you
>can't have reliable results.

>> Let me share one thing. There are so many type casting in the
>> code. I doubt the problem may be there. But I do not understand why
>> the code works fine with debug mode?

>Why do you need so much casting?  Any casts other than
>once-in-a-rare-while cast suspicion on a design.  It forfeits an
>incredible amount of help that the compiler COULD be giving you in
>tracking down problems.

>> If anyone know the answer. Please reply.

>I don't know the answer, but I'd guess it's the debug libraries whose
>behavior is different.  Perhaps you can link the release RTL into a
>debug build, so you can look at your code in the de{*filter*}, but not use
>the "help" of their debug RTL.  (I'm not sure if you can do this, but
>if you can, you should.)

Or enable debug info for the release build.

--
Doug Harrison [VC++ MVP]
Eluent Software, LLC
http://www.*-*-*.com/
Tools for Visual C++ and Windows



Mon, 17 Feb 2003 13:48:52 GMT  
 Memory Access Violation in Release Mode


Fri, 19 Jun 1992 00:00:00 GMT  
 Memory Access Violation in Release Mode
I am badly stuck on this one and would be grateful for any help:

The company which I am working for has a program which was written in
visualC++.  The program uses Access'97 as a database backend.  The
frontend is all done in VC++.

The program works fine under win'95 /'98.  When we tried to install on a
winNT or a win2000 system we had a display problem:

The main window, which should contain a list of the database entries,
would only show the first entry.  The rest would show up blank.  Upon
clicking on the blank, the data which should be there would appear.

The program was written on VisualC++ version 5.0 and service pack 3 had
already been run on VC++. (the service pack updated comctl32.* etc.)
I didn't find any patches on www.microsoft.com which seemed to be intended
for this problem.

If anyone could sugest a solution I would be most grateful.

Regards
Joshua Mentz

----------------------------------------------------------------------------
" Never thank a larny for giving you bread.
          Your street is not a supermarket. "
                           -D Lambert (2000)



Mon, 17 Feb 2003 14:59:01 GMT  
 Memory Access Violation in Release Mode


Fri, 19 Jun 1992 00:00:00 GMT  
 Memory Access Violation in Release Mode

Hi Dan,

I am extremely sorry. I will do that. I will cross post the message. Frankly
speaking., I didn't know the concept of cross posting.

Thanks again for advice.

Regards,

Atul


Quote:
> Atul

> I saw your post on at least three news groups. If you
> *must* post to more than one group, please cross post.
> Don't multipost.  Multiposting means there is a copy
> of your post on each group. Cross posting means there
> is only one copy that is shared across the groups.
> Also, many news readers will only show cross posted
> messages once.  So all round crossposting is preferred
> to multiposting.  People will be happier with you, and
> you will get more and better responses.

> However, posting only to the most relevant group, one
> singular group, is the most preferred. If you don't get
> an answer there, then look further.  People will be the
> most happy with you, and you will get the best response.

> Anyway, I posted an answer to this on another group.
> You'll have to hunt for it if you want it.
> --
> Dan Evens
> Standard disclaimers etc. No spam please.



Mon, 17 Feb 2003 03:00:00 GMT  
 Memory Access Violation in Release Mode


Fri, 19 Jun 1992 00:00:00 GMT  
 Memory Access Violation in Release Mode

You aren't providing anywhere near enough information to be able to even
guess at a problem.

How are these lists implemented?  List Boxes?  ComboBoxes?  ActiveX
controls?  Custom Drawn stuff?


Quote:
> I am badly stuck on this one and would be grateful for any help:

> The company which I am working for has a program which was written in
> visualC++.  The program uses Access'97 as a database backend.  The
> frontend is all done in VC++.

> The program works fine under win'95 /'98.  When we tried to install on a
> winNT or a win2000 system we had a display problem:

> The main window, which should contain a list of the database entries,
> would only show the first entry.  The rest would show up blank.  Upon
> clicking on the blank, the data which should be there would appear.

> The program was written on VisualC++ version 5.0 and service pack 3 had
> already been run on VC++. (the service pack updated comctl32.* etc.)
> I didn't find any patches on www.microsoft.com which seemed to be intended
> for this problem.

> If anyone could sugest a solution I would be most grateful.

> Regards
> Joshua Mentz

> --------------------------------------------------------------------------
--
> " Never thank a larny for giving you bread.
>           Your street is not a supermarket. "
>            -D Lambert (2000)



Mon, 17 Feb 2003 03:00:00 GMT  
 
 [ 19 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Memory Access Violation in Release mode only

2. Memory Access Violation in Release Mode-Solution Found

3. Memory Access Violation in Release Mode-Solution Found

4. Memory Access Violation in Release Mode-Solution Found

5. Memory Access Violation in Release Mode

6. Access Violation Exception in Release mode

7. access violation in release mode

8. Access Violation in Release Mode

9. Access Violation (NTDLL.DLL): 0xC0000005 only in Debug Mode on NT and Win2k

10. Access violation in user32.dll in debug mode

11. strange access violation in debug mode

12. Access violation in _QIThunk::Release

 

 
Powered by phpBB® Forum Software