RTC_NO_ABORT=1 a.out 20

$Runtime Error: out of bounds buffer pointed by 0x40010350 has 10 bytes (variable "b"), writing at 0x40010350+0, 20 bytes ("memset", line 0)

(0)0x0000000004004770 _rtc_raise_fault + 0x560 at rtc_utils.c:164 [./a.out]

(1)0x00000000040089d0 _rtc_oob_check_unknown_bounds + 0x430 at rtc_bounds.c:480 [./a.out]

(2)0x60000000c5f52440 libc_mem_common + 0x280 at infrtc.c:3286 [lib/hpux32/librtc.so]

(3)0x60000000c5f53650 _memset + 0x80 at infrtc.c:3521 [lib/hpux32/librtc.so]

(4)0x0000000004003760 main + 0x170 at rttest3.c:27 [./a.out]

(5)0x60000000c0049c50 main_opd_entry + 0x50 [/usr/lib/hpux32/dld.so]

Runtime Error: out of bounds buffer pointed by 0x400a1890 has 40 bytes

(allocation stack trace: 0x040035c2, 0x04003612, 0xc0049c42), writing at 0x400a1890-2054847100, 4 bytes ("rttest3.c", line 29)

(0)0x0000000004004770 _rtc_raise_fault + 0x560 at rtc_utils.c:164 [./a.out]

(1)0x0000000004008790 _rtc_oob_check_unknown_bounds + 0x1f0 at rtc_bounds.c:465 [./a.out]

(2)0x00000000040037b0 main + 0x1c0 at rttest3.c:29 [./a.out]

(3)0x60000000c0049c50 main_opd_entry + 0x50 [/usr/lib/hpux32/dld.so] Memory fault(coredump)

+check=globals

The +check=globals option enables runtime checks to detect corruption of global variables by introducing and checking "guards" between them, at the time of program exit. Setting environment variable RTC_ROUTINE_LEVEL_CHECKwill also enable the check whenever a function compiled with this option returns.

For this purpose, the definition of global is extended to be all variables that have static storage duration, including file or namespace scope variables, function scope static variables, and class (or template class) static data members.

+check=lock

The +check=lock option enables checking of C and C++ user applications that use pthreads. The option reports violations of locking discipline when appropriate locks are not held while accessing shared data by different threads. The check is based on the lockset method for detecting locking discipline violations, as described in the Eraser tool article at http://

citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.22.3256&rep=rep1& type=pdf.

Note that +check=all does not enable +check=lock. Also note that since +check=lock requires instrumenting each memory access, it can result in a considerable slowdown of the application at runtime. +check=lock also increases the memory consumption of the instrumented application.

The check is performed on each memory access. It detects violations in locking discipline for mutual exclusion locks (mutexes) for applications using posix threads. When the locking discipline is violated, it is reported along with the line number and the address for which the violation occurs. Consider the following code example:

#include <stdio.h> #include <unistd.h> #include <pthread.h> unsigned long things_done=0;

pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER; void *thread1(void *arg) {

pthread_mutex_lock(&mutex1); things_done++; pthread_mutex_unlock(&mutex1); return 0;

}

78 Command-Line Options

Page 78
Image 78
HP C/aC++ for PA-RISC Software manual +check=globals, +check=lock