- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Extra Arguments under Workshop Debugger
Operating System - HP-UX
1755744
Members
2452
Online
108837
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2002 11:14 AM
тАО11-01-2002 11:14 AM
Extra Arguments under Workshop Debugger
I'm running WorkShop 6 on a Solaris 8 system. I have a few questions regarding
the debugger. Given the following trival C program
#include
#include
int main() {
char X[10] = "test1";
char Y[10];
memcpy(Y,X,0x40000);
printf("Y=%s\n",Y);
}
When I run this under the debugger I get a SEGV with the following output:
main()
__align_cpy_1(0xffbefff0, 0xffbefffa, 0x3f9c8, 0x7, 0x3f9c0, 0xffbef9b8)
I have a couple of questions/comments on this:
1) I'm assuming __align_cpy_1 is a subroutine of memcpy (right?).
2) Where are there 6 arguments to this when memcpy only takes 3? I'm
asking because we have an actual customer problem that, when run under
WorkShop, shows the SEGV to occur on _memcpy itself, but there are still
6 rather than 3 arguments. Where are these extra 3 arguments coming
from?
3) From experiments, the 3rd argument, 0x3f9c8, is, as expected, the
length. However, shouldn't it be 0x40000?
the debugger. Given the following trival C program
#include
#include
int main() {
char X[10] = "test1";
char Y[10];
memcpy(Y,X,0x40000);
printf("Y=%s\n",Y);
}
When I run this under the debugger I get a SEGV with the following output:
main()
__align_cpy_1(0xffbefff0, 0xffbefffa, 0x3f9c8, 0x7, 0x3f9c0, 0xffbef9b8)
I have a couple of questions/comments on this:
1) I'm assuming __align_cpy_1 is a subroutine of memcpy (right?).
2) Where are there 6 arguments to this when memcpy only takes 3? I'm
asking because we have an actual customer problem that, when run under
WorkShop, shows the SEGV to occur on _memcpy itself, but there are still
6 rather than 3 arguments. Where are these extra 3 arguments coming
from?
3) From experiments, the 3rd argument, 0x3f9c8, is, as expected, the
length. However, shouldn't it be 0x40000?
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2002 01:37 PM
тАО11-01-2002 01:37 PM
Re: Extra Arguments under Workshop Debugger
I don't know what "Workshop" is or what it has
to do with HP-UX, but your use of memcpy()
is a little strange. You're copying 256 kb from
X to Y, but X is only 10 bytes long. Y will
get the value "test1" and the contents of
memory following Y will get corrupted. It may
in fact corrupt X itself, because X may follow
Y in memory. Depending on the memory
layout of your OS it may also trash the
program stack, which could cause the
error messge you are seeing.
memcpy() is typically used for copying
arbitrary binary data, not strings. The
copy would be better implemented using
strncpy(), which will stop after it hits the
null byte at the end of X or if there's not
enough space in Y to receive the contents.
As for __align_cpy_1, it's probably a subroutine
in libc or perhaps in the kernel. _memcpy
is not the same as memcpy(); it's probably
a subroutine in libc as well. (System libraries
like libc usually employ a leading underscore
on internal subroutine names and internal
variables, which is why you should avoid
using a leading underscore in user-defined
subroutine or variable names.)
At any rate, memcpy() probably calls
_memcpy and/or __align_cpy_1 and
automatically supplies the 6 arguments
as needed. These may include the 3
arguments you passed to memcpy(), but
you cannot depend on any relationship
between the two sets.
Unless you you suspect there's a bug
in your vendor's libc or unless you are
really interested in its inner workings,
you probably shouldn't worry about the
arguments memcpy() passes to its
subroutines.
HTH
to do with HP-UX, but your use of memcpy()
is a little strange. You're copying 256 kb from
X to Y, but X is only 10 bytes long. Y will
get the value "test1" and the contents of
memory following Y will get corrupted. It may
in fact corrupt X itself, because X may follow
Y in memory. Depending on the memory
layout of your OS it may also trash the
program stack, which could cause the
error messge you are seeing.
memcpy() is typically used for copying
arbitrary binary data, not strings. The
copy would be better implemented using
strncpy(), which will stop after it hits the
null byte at the end of X or if there's not
enough space in Y to receive the contents.
As for __align_cpy_1, it's probably a subroutine
in libc or perhaps in the kernel. _memcpy
is not the same as memcpy(); it's probably
a subroutine in libc as well. (System libraries
like libc usually employ a leading underscore
on internal subroutine names and internal
variables, which is why you should avoid
using a leading underscore in user-defined
subroutine or variable names.)
At any rate, memcpy() probably calls
_memcpy and/or __align_cpy_1 and
automatically supplies the 6 arguments
as needed. These may include the 3
arguments you passed to memcpy(), but
you cannot depend on any relationship
between the two sets.
Unless you you suspect there's a bug
in your vendor's libc or unless you are
really interested in its inner workings,
you probably shouldn't worry about the
arguments memcpy() passes to its
subroutines.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2002 05:28 AM
тАО11-04-2002 05:28 AM
Re: Extra Arguments under Workshop Debugger
Sorry, please ignore this post.
This was meant for the Solaris
newsgroup (I'm juggling too many
platforms lately).
This was meant for the Solaris
newsgroup (I'm juggling too many
platforms lately).
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP