- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Treatment of Stack Space used for Function Calls
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
03-10-2010 04:41 AM
03-10-2010 04:41 AM
Compiler : aCC
Platform : IA
OS : 11iv3
Doubt :
My question is over the stack space returned by a function after the function returns.
When a function call returns, what happens to the stack space? Is it cleaned (zeroed out)?
When a new function call happens in the same context is the same space re-used for that function or a new block of memory (but not the one used in the previously returned function) is allocated? Is there a way by means of flag to tell the Compiler to erase and then allocate.
Is this behavior of Stack Space Compiler dependent? or OS Dependent?
Has it anything to do with the Linker/Loader? (I don't think so tough ...)
Thanks in advance.
Solved! Go to Solution.
- Tags:
- stackframe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2010 05:13 AM
03-10-2010 05:13 AM
Re: Treatment of Stack Space used for Function Calls
main() {
char *a[2];
foo (a);
bar (a);
}
foo() {
char c[20], d[20];
a[0]=c;
a[1]=d;
}
bar() {
printf(a[0],a[1]);
}
Here, even tough the arrays a and b have been destroyed after the function call of foo() has been done with, they still show the same value when the value of a is printed in the bar() function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2010 08:25 AM
03-10-2010 08:25 AM
SolutionIt stays until overwritten. This could be randomly due to signals.
>is the same space re-used for that function
That's why it's called a stack, it is reused.
>Is there a way by means of flag to tell the compiler to erase and then allocate.
No. You must initialize your own objects.
>even though the arrays a and b have been destroyed
(Only C++ objects are destroyed.)
>they still show the same value when the value of a is printed in the bar() function.
This is illegal, you shouldn't depend on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2010 12:15 PM
03-12-2010 12:15 PM
Re: Treatment of Stack Space used for Function Calls
http://forums.itrc.hp.com/service/forums/helptips.do?#33
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2010 06:01 AM
03-13-2010 06:01 AM
Re: Treatment of Stack Space used for Function Calls
t#