Hi Jim,
I think what you're seeing is a result of memcpy() and family being
overridden as well when you use LD_PRELOAD. Without LD_PRELOAD you
get the behaviour shown in the tutorial but with LD_PRELOAD you get
additional debugging versions of memcpy(), strcpy(), etc. that check
allocation bounds and won't perform the operation if they overrun
their bounds.
What you're seeing is the log file entries of the debugging version
of memcpy() correctly telling you that it's being asked to perform an
illegal operation. The memcpy() is being called from puts(). You're
probably getting a hang in the program because the terminating zero
was never written to the string and puts() is failing.
Thanks,
Graeme.
--- In mpatrol@yahoogroups.com, "jmg_000" <jim@...> wrote:
>
> Hi,
>
> Having a little trouble getting mpatrol working using LD_PRELOAD on
> HP-UX 11.11 (PA-RISC). I've built a test program that included
> mpatrol.h, and that seemed to work as expected.
>
> The program I'm trying is part of the 1.4.8 distribution,
> tests/tutorial/test1.c, built like so:
> cc -Ae -g test1.c -o test1
>
> Runs fine without LD_PRELOAD. When I try LD_PRELOAD, the program
does
> not work correctly, but I do get an mpatrol.log. Here is a sample
run:
>
> host1:
LD_PRELOAD=/usr/src/mpatrol/build/unix/libmpatrol.sl.1.4 ./test1
> first line
>
> second line
>
>
> third line
>
> host1:
>
> In addition, ctrl-d is not recognized as EOF, so I must use ctrl-c
or
> kill the process. Here is the log:
>
> @(#) mpatrol 1.4.8 (02/01/08)
> Copyright (C) 1997-2002 Graeme S. Roy
>
> This is free software, and you are welcome to redistribute it under
> certain
> conditions; see the GNU Library General Public License for details.
>
> For the latest mpatrol release and documentation,
> visit http://www.cbmamiga.demon.co.uk/mpatrol.
>
> operating system: UNIX
> system variant: HP/UX
> processor architecture: HP PA/RISC
> processor word size: 32-bit
> object file format: BFD
> dynamic linker type: HP/UX
>
> Log file generated on Fri Jan 5 10:27:36 2007
>
> read 1698 symbols from /usr/src/mpatrol/build/unix/libmpatrol.sl.1.4
> read 3526 symbols from /usr/lib/libcl.2
> read 28 symbols from /usr/lib/libisamstub.1
> read 4510 symbols from /usr/lib/libc.2
> read 61 symbols from /usr/lib/libdld.2
> read 0 symbols from /opt/graphics/OpenGL/lib/libogltls.sl
> read 58 symbols from ./test1
>
> MEMCOPY: memcpy (0x40005590, 0x400055A8, 11 bytes, 0x00) [-|-|-]
> 0xC01C9CA8 memccpy+128
> 0xC0203AC0 __puts_unlocked+320
> 0xC0203CB0 puts+176
> 0x00002BAC main+104
> 0xC0143478 _start+192
> 0x00001840 $START$+376
>
> ERROR: [RNGOVF]: memcpy: range [0x40005590,0x4000559A] overflows
> [0x40005590,0x40005599]
> 0x40005590 (10 bytes) {malloc:93:0} [-|-|-]
> 0x00002A90 strtoupper+48
> 0x00002B88 main+68
> 0xC0143478 _start+192
> 0x00001840 $START$+376
>
> MEMCOPY: memcpy (0x400075B0, 0x400055A8, 12 bytes, 0x00) [-|-|-]
> 0xC01C9CA8 memccpy+128
> 0xC0203AC0 __puts_unlocked+320
> 0xC0203CB0 puts+176
> 0x00002BAC main+104
> 0xC0143478 _start+192
> 0x00001840 $START$+376
>
> ERROR: [RNGOVF]: memcpy: range [0x400075B0,0x400075BB] overflows
> [0x400075B0,0x400075BA]
> 0x400075B0 (11 bytes) {malloc:95:0} [-|-|-]
> 0x00002A90 strtoupper+48
> 0x00002B88 main+68
> 0xC0143478 _start+192
> 0x00001840 $START$+376
>
> MEMCOPY: memcpy (0x400075B0, 0x400055A8, 11 bytes, 0x00) [-|-|-]
> 0xC01C9CA8 memccpy+128
> 0xC0203AC0 __puts_unlocked+320
> 0xC0203CB0 puts+176
> 0x00002BAC main+104
> 0xC0143478 _start+192
> 0x00001840 $START$+376
>
> ERROR: [RNGOVF]: memcpy: range [0x400075B0,0x400075BA] overflows
> [0x400075B0,0x400075B9]
> 0x400075B0 (10 bytes) {malloc:96:0} [-|-|-]
> 0x00002A90 strtoupper+48
> 0x00002B88 main+68
> 0xC0143478 _start+192
> 0x00001840 $START$+376
>
> So, I think I've built something wrong, but I don't know what. I
built
> the bfd and libiberty libs from the 2.17 distribution of binutils.
>
> Any suggestions appreciated!
>
> Thanks,
>
> Jim Gallagher
>