* sprintf problem under OSF/1
@ 1994-02-16 4:49 Chris Zagar
1994-02-16 16:54 ` David Boyce
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Chris Zagar @ 1994-02-16 4:49 UTC (permalink / raw)
I'm sorry if I'm asking a common problem, but we just got our first
Alpha and it is driving me crazy. I have an existing application that
I am trying to port. I have compiled it with the -taso option, and it
compiles and links without error. However, when I run it, every time
it encounters simple sprintf errors, it dies with a segmentation
fault. Does this sound familiar to anyone? Also, is there any
place that I can find information on what is required to port applications
to OSF/1?
Thanks for any information.
---------------------------------------------------------------------------
/\ /\ Chris Zagar Maricopa Community Colleges
/ \ / \ Asst. Prog. Mgr./Networking 2411 West 14th Street
/ /\// /\ \ Bitnet: ZAGAR@MARICOPA Tempe, AZ 85281
\/ \/ \/ Internet: zagar@names.maricopa.edu (602) 731-8838
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: sprintf problem under OSF/1
1994-02-16 4:49 sprintf problem under OSF/1 Chris Zagar
@ 1994-02-16 16:54 ` David Boyce
1994-02-18 3:42 ` sprintf problem under OSF/1 on Alpha Chris Zagar
1994-02-18 17:48 ` sprintf problem under OSF/1 Andre Beck
2 siblings, 0 replies; 4+ messages in thread
From: David Boyce @ 1994-02-16 16:54 UTC (permalink / raw)
>> I'm sorry if I'm asking a common problem, but we just got our first
>> Alpha and it is driving me crazy. I have an existing application that
>> I am trying to port. I have compiled it with the -taso option, and it
>> compiles and links without error. However, when I run it, every time
>> it encounters simple sprintf errors, it dies with a segmentation
>> fault. Does this sound familiar to anyone? Also, is there any
>> place that I can find information on what is required to port applications
>> to OSF/1?
>> Thanks for any information.
First: as a point of nomenclature, the problem is not with sprintf
under OSF/1, as the subject says. It's with sprintf on an Alpha, i.e.
it's a 64-bit porting problem. You'd have the same problem porting
your application to an Alpha running VMS or NT, and you wouldn't have
it porting to another platform running OSF/1.
As for the sprintf problem: the -taso option will only work around the
most common coding-portability mistake, which is assuming a pointer
will fit in an integer and vice versa. If your code assumes that a
long is the same size as an int, -taso can do nothing about that. In
particular, when using *printf the following two (incorrect)
constructs will work correctly on a platform where
sizeof(int)==sizeof(long):
printf("%d", <long>);
printf("%ld", <int>);
The print routines examine the format string to determine the sizes to
expect for subsequent arguments. On most machines ints and longs are
both 32 bits and the above, though sloppy, still works. But on an
Alpha the first printf will be looking for a 32-bit (int-sized)
quantity and get 64, whereas the second will look for 64 and get 32.
I'd guess that your problems come from this.
Take a look at the lint(1) man page on an Alpha and look up the -Q
option. Pay particular attention to the 'f' suboption. Running
lint -Q<everything-but-f> *.[ch]
or similar on your application should show where format string
mismatches occur.
--
David Boyce dsb@osf.org 617-621-8963
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: sprintf problem under OSF/1 on Alpha
1994-02-16 4:49 sprintf problem under OSF/1 Chris Zagar
1994-02-16 16:54 ` David Boyce
@ 1994-02-18 3:42 ` Chris Zagar
1994-02-18 17:48 ` sprintf problem under OSF/1 Andre Beck
2 siblings, 0 replies; 4+ messages in thread
From: Chris Zagar @ 1994-02-18 3:42 UTC (permalink / raw)
Well, I have some further information and I'm still hoping it will trigger
something in someone's mind. The problem occurs whether I use -taso or
not. This simple statement causes the problem:
char temp[80];
char temp1[80];
strcpy(temp1, "Testing");
sprintf(temp, "%s", temp1);
Now, what is really interesting is that a code fragment like this will work
if I compile it by itself. However, if I then link this with the object
modules of my application (minus the main section of the application), with
no reference out of main to any of the modules, then run the relinked
program, I get a segmentation fault on the sprintf statement.
>I'm sorry if I'm asking a common problem, but we just got our first
>Alpha and it is driving me crazy. I have an existing application that
>I am trying to port. I have compiled it with the -taso option, and it
>compiles and links without error. However, when I run it, every time
>it encounters simple sprintf errors, it dies with a segmentation
>fault. Does this sound familiar to anyone? Also, is there any
>place that I can find information on what is required to port applications
>to OSF/1?
---------------------------------------------------------------------------
/\ /\ Chris Zagar Maricopa Community Colleges
/ \ / \ Asst. Prog. Mgr./Networking 2411 West 14th Street
/ /\// /\ \ Bitnet: ZAGAR@MARICOPA Tempe, AZ 85281
\/ \/ \/ Internet: zagar@names.maricopa.edu (602) 731-8838
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: sprintf problem under OSF/1
1994-02-16 4:49 sprintf problem under OSF/1 Chris Zagar
1994-02-16 16:54 ` David Boyce
1994-02-18 3:42 ` sprintf problem under OSF/1 on Alpha Chris Zagar
@ 1994-02-18 17:48 ` Andre Beck
2 siblings, 0 replies; 4+ messages in thread
From: Andre Beck @ 1994-02-18 17:48 UTC (permalink / raw)
In article <2js8kl$mhc@names.maricopa.edu>, zagar@names.maricopa.edu (Chris Zagar) writes:
|>I'm sorry if I'm asking a common problem, but we just got our first
|>Alpha and it is driving me crazy. I have an existing application that
|>I am trying to port. I have compiled it with the -taso option, and it
|>compiles and links without error. However, when I run it, every time
|>it encounters simple sprintf errors, it dies with a segmentation
|>fault. Does this sound familiar to anyone? Also, is there any
|>place that I can find information on what is required to port applications
|>to OSF/1?
|>
Dunno whether it's the error, but some old programs assume BSD behavior
of sprintf (return string buffer address), whereas OSF will likely provide
a POSIX compliant one which returns the number of characters processed.
--
+-o-+--------------------------------------------------------+-o-+
| o | \\\- Brain Inside -/// | o |
| o | ^^^^^^^^^^^^^^ | o |
| o | Andre' Beck (ABPSoft) Andre_Beck@IRS.Inf.TU-Dresden.de | o |
+-o-+--------------------------------------------------------+-o-+
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1994-02-18 17:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-02-16 4:49 sprintf problem under OSF/1 Chris Zagar
1994-02-16 16:54 ` David Boyce
1994-02-18 3:42 ` sprintf problem under OSF/1 on Alpha Chris Zagar
1994-02-18 17:48 ` sprintf problem under OSF/1 Andre Beck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox