vasa <vv40in@rambler.ru> wrote:
: Hi,
: Please,
: anybody , say me what is my wrong?
: I compile tests from
: http://qdn.qnx.com/support/docs/neutrino/prog/hat.html
: such as
: // file xxx.c
: #include<malloc_g/malloc.h>
: void f(){
: char *p;
: mallopt(MALLOC_CKACCESS, M_HANDLE_ABORT);
: p = malloc(strlen(“hello”));
: strcpy(p, “hello, there!”);
: }
: main(){
: f1();
: }
: qcc -o xxx xxx.c -Bdynamic -lmalloc_g
: it does not work!
: Q: WHY?
For some reason we seem to have different version
of libmalloc_g lying around. BTW the other poster
did give some valuable info.
Try :
qcc -g -o x x.c -lmalloc_g -I /usr/include/malloc_g
LD_LIBRARY_PATH=/usr/lib/malloc_g ./x
MALLOC Warning from strcpy() (called from instruction preceding 0x08048541):
Pointer within malloc region, but outside of malloc data bounds
This error is probably associated with the following allocation:
A call to malloc for 5 bytes in an unknown file near 8048528.
This was the 15th call to malloc.
@ [0x0804849C]
@ (main+0x0000000B)[0x08048553]
@ [0x08048541]
@ libmalloc.so.2:(strcpy+0x00000023)[0xB035D133]
@ libmalloc.so.2:(DBstrcpy+0x000000CE)[0xB035D206]
@ libmalloc.so.2:(malloc_check_data+0x00000094)[0xB03575B0]
: -----------------
: next
: // file xxx.c
: #include<malloc_g/malloc.h>
: main(){
: void *p;
: for(i=0;i<1000;i++) p=malloc(1000);
: malloc_dump(1);
: }
: it was compiled OK as follows:
: qcc -o xxx xxx.c -Bdynamic -lmalloc_g
: but during execution it said (like that):
: unresolved symbol “malloc_dump”
: Q: what’s the matter???
Yes. You are using the wrong malloc_g shared lib.
: -----------------------
: next
: if I do
: {
: for(i=0;i<1000;i++) p=malloc(1000);
: h=dlopen("/usr/lib/malloc_g.so",…)
: f=dlsym(h, “malloc_dump”);
: f(1);
: }
: it outputs empty list!
: Q: what’s the matter???
: Thanks a much!
: vasa