new and delete

I have issues with Array Bound Read Error with purifier for string variables. This is happening only after optimization. I would like to override global new and delete... The class level scope overriding will not solve my problem.

Is there anyone have any suggestions on how to override global new and delete operator, please let me know.

What are the options do I have to fix Array Bound Read issues without overriding new and delete operators....

[468 byte] By [Sara_Kan] at [2007-11-26 11:31:11]
# 1

You probably don't want to override global new/delete. In particular, it won't help your ABR problems. Even with an optimized version, Purify should be giving you both the stack at the moment of the error and at the moment that the memory at the site of the ABR was allocated (if on the heap).

There are also printf type functions that purify can use to write to its logfile. Sprinkle them liberally and you should be able to trace down the fault.

Paul

Paul_Floyd at 2007-7-7 3:46:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

You can replace the global new and delete. Any good C++ textbook should explain how. If you do it, be sure to override in pairs: the throwing and non-throwing versions, and the corresponding new/delete pairs. (The requirements on replacing new and delete are too lengthy to list here.)

But in Sun C++, the global new and delete operators simply call malloc and free, and are certainly not the source of the ABRs. You can replace the underlying malloc and free with debugging versions. Try

man libumem

man watchmalloc

for suggestions.

An ABR can a false positive from Purify. Purify depends strongly on unstable details of compiler code generation. Purify tells you which versions of Sun C++ it is suitable for. You can get incorrect reports with different compiler versions.

An ABR can be due to a bug in the C++ runtime library, or in your own code. You don't say where the error is coming from. If you post the error messages, I might be able to make some suggestions.

Finally, if you are running on a SPARC system, you can run your program under dbx with Run-Time Checking enabled. It will report problems and direct you to where they occur. In dbx, use the command

check -all

to enable all runtime checks. (RTC on x86 and x64 platforms is limited)

clamage45 at 2007-7-7 3:46:57 > top of Java-index,Development Tools,Solaris and Linux Development Tools...