tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* oddity with debugger and sprintf( )
@ 2004-08-12 22:21 Eiler, James A.
  0 siblings, 0 replies; only message in thread
From: Eiler, James A. @ 2004-08-12 22:21 UTC (permalink / raw)


All,

I've tried the following on several Alphas with different versions of T64 (4.0G, 5.1A, 5.1B) (and different versions of dbx and ladebug) and got the same result every time.

My little C program is as follows:

     1  #include <stdio.h>
     2  #include <string.h>
     3
     4  main( )
     5  {
     6     char sName [ 16 ];
     7     char sString[ 256 ];
     8     int  iStatus;
     9
    10     strcpy( sName, "bar" );
    11
    12     iStatus = 1;
    13
    14     sprintf( sString, "%s %s %s %s %s %s %s",
    15              sName, sName, sName, sName, sName, sName, sName );
    16
    17  }


If I compile it and run it with the debugger (dbx or ladebug), set a breakpoint at line 12, then run it to the breakpoint, then goto line 14, then do a next, I get a segmentation violation:

alpha1-mst> cc jaetest.c -g2 -o jaetest
alpha1-mst> dbx jaetest
dbx version 5.1
Type 'help' for help.

main:  10  strcpy( sName, "bar" );
(dbx) b 12
[2] stop at "jaetest.c":12
(dbx) r
[2] stopped at   [main:12 ,0x12000118c]         iStatus = 1;
(dbx) goto 14
(dbx) n
signal Segmentation fault at >*[strlen, 0x3ff800d27e0]  ldq_u   t0, 0(a0)

However, if I just run it (from the command prompt), it runs just fine.

And if I run in from the debugger and just "next" through it, it also works just fine.

Lastly, if I change the sprintf( ) to have less than 5 "%s" conversion strings, it also works just fine!

I stumbled across this quite by accident while trying to debug one of my programs, and this is the essence of what I was running into.

Has anyone seen anything like this before?

Thanks!

Jim


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-08-12 22:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-12 22:21 oddity with debugger and sprintf( ) Eiler, James A.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox