LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-23-2015, 03:47 PM   #1
IndianScorpion
LQ Newbie
 
Registered: Dec 2014
Posts: 24

Rep: Reputation: Disabled
How to test the stack size a c complex program requires on LINUX?


How to test the stack size a c complex program requires on LINUX? (ulimit -s)
 
Old 06-24-2015, 01:28 AM   #2
penduin
LQ Newbie
 
Registered: Aug 2012
Distribution: Slackware
Posts: 12

Rep: Reputation: Disabled
I'm not sure I understand your question, but it will depend on what is declared in each stack frame, how much recursion is used, and so on. Is there any way to post a simplified version of what you're doing, to shine some more light on your question?

Are you looking to use the smallest feasible stack for a given program? Debugging a stack overflow? I think the more you can say about what you're trying to accomplish, the better people will be able to help.
 
Old 06-24-2015, 03:58 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,021

Rep: Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343
probably valgrind (or other tool) can analyze your code. That means you run it and use it and finally valgrind will create a report for you about memory usage, heap, stack, whatever. But probably there are other, better tools available out there.
 
Old 06-24-2015, 06:48 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Hello?

Didn't we take Algorithms in school and learn that modeling maximum stack size is technically unsolvable?

You can approximate this. But things like optimization, indirect function pointers, recursive functions, and overall system complexity make it near impossible to attain anything accurate.

There are techniques to detect overflow and monitor stack usage, however they require pre-defined conditions such as known stack locations, size, and pre-seeding of the stack with patterns, while monitoring software is also used.
 
Old 06-24-2015, 03:30 PM   #5
IndianScorpion
LQ Newbie
 
Registered: Dec 2014
Posts: 24

Original Poster
Rep: Reputation: Disabled
@rtmistler understood that stack size is a runtime thing, can't get it until actually running it.
Just need to give users some ulimit -s guidance instead of using unlimited to run the program without crash.
For example, Oracle 11g suggest a minimal stack size of 10240K, up to 30720K

---------- Post added 06-24-15 at 03:31 PM ----------

@pan64 do you mean tool massif in valgrind?
 
Old 06-25-2015, 12:31 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,021

Rep: Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343Reputation: 7343
yes, for example.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
To find the used stack size per thread in Linux. kauuttt Programming 4 08-31-2012 03:01 AM
Max Stack Size limit on Linux 2.4 rhegde Debian 0 08-08-2006 02:18 PM
cannot enable executable stack as shared object requires abefroman Linux - General 2 03-20-2004 11:28 AM
cannot enable executable stack as shared object requires worldmagic Fedora 0 01-20-2004 03:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration