From: "Eiler, James A." <James.Eiler@alcoa.com>
Subject: oddity with debugger and sprintf( )
Date: Thu, 12 Aug 2004 18:21:35 -0400 [thread overview]
Message-ID: <5CE3000C0721A24F9575EA3F4F1B691C040FA2E0@noaadc-mxu25.noa.alcoa.com> (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
reply other threads:[~2004-08-12 22:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox