Questions tagged [stack]
The stack tag has no summary.
50 questions
2
votes
1
answer
218
views
Dump bash stack trace on error with function parameters
With the function
function fail() {
local msg="$*"
echo $msg at
for i in ${!FUNCNAME[@]}; do
echo " ${FUNCNAME[$i]} ${BASH_SOURCE[$i]}:${BASH_LINENO[$i]}"
done
exit ...
1
vote
1
answer
225
views
How does the linux kernel know where to put its heap?
When setting up dynamic memory allocation, the Linux kernel has got to choose a place to put its heap, no? How does it avoid overriding its own stack or the stack growing and overriding the heap later?...
0
votes
0
answers
39
views
Host docker stacks for reverse proxy as traefik, and observability/logging monitoring stacks
First of all, I tried to keep this post as clear as possible, and looked on stack websites for the below stack composes, but I failed to assemble them together in a sense to provide a standalone ...
1
vote
1
answer
214
views
Why is the stack segment not explicit in ELF files?
Everything mapped in memory is explicit in ELF files except the stack segment. The stack segment is mapped automatically.
Why is the stack segment not like other segments, with explicit settings in ...
0
votes
1
answer
281
views
How to change the kernel stack size for the kernel modules in Ubuntu 14.04?
I want to change the kernel stack size of Ubuntu 14.04 for the kernel modules. However, with menuconfig, or .config I couldn't find the CONFIG_THREAD_STACK_SIZE option.
I just want to increase the ...
1
vote
0
answers
46
views
Retrieving the process descriptor during syscall
In Linux, there is a per-process kernel stack that stores at the bottom of it (or top if the stack grows upwards) a small struct named thread_info, which in turn points to the task_struct of the ...
0
votes
1
answer
192
views
Running command 'cat /proc/<pid>/stat | cut -d" " -f29' to get stack pointer , is always showing stack pointer as zero
Iam trying to get the stack pointer of some thread using the /proc//stat, whenever i run the command,cat /proc/<pid>/stat | cut -d" " -f29 i end up getting zero, but when i run sudo ...
1
vote
2
answers
1k
views
System calls involved in stack and heap allocation
In the process address space, there is the stack and the heap. When a function is called, or even when a local variable is declared, it uses the stack; the kernel must assign physical address and ...
1
vote
1
answer
1k
views
Pactical limits to `ulimit -s 1048576`?
Linux allows ulimit -s unlimited, which allows programs to exhaust system memory and crash the computer. So, generally no good.
But what are the drawbacks to a significantly higher limit to the ...
1
vote
1
answer
1k
views
How do I change the destination IP of all outgoing packets (especially DNS)?
I have a Raspberry Pi 4 with the latest build of (Debian) raspberry pi OS. I am trying to configure iptables to redirect all traffic coming from the Pi (with ) to another machine (lets say with an IP ...
1
vote
1
answer
587
views
What purpose does ELF's stack-size metadata have?
I was reading the Rust Unstable Book, and I saw a new feature for emit-stack-sizes,
The rustc flag -Z emit-stack-sizes makes LLVM emit stack size metadata.
It goes on to say
NOTE: This LLVM feature ...
1
vote
1
answer
380
views
How to get linux stack bounds?
How can I get the address bounds of the Linux stack using syscalls without resorting to using exception handlers? I can get the stack size using getrlimit, but it doesn't say where the stack starts ...
2
votes
1
answer
2k
views
Why is Linux stack size limit so low on 64-bit machines?
As far as I know the Linux stack size limit is 8 MB, but on 64-bit machines there's no reason why it couldn't be massively increased, e.g. to 4 GB. This would allow programmers to mostly not worry ...
4
votes
2
answers
2k
views
Why is the stack argument required for the clone wrapper?
I've been carefully reading the linux man page for clone(), and I understand the difference between the clone() wrapper and the "raw" system call. But what I don't understand is why the ...
0
votes
2
answers
482
views
To get in variable, a directory've been pushd [duplicate]
How do I use, i.e. to have in bash variable, a directory just've been pushd, and not to do popd command ?
1
vote
2
answers
179
views
Where are the files related to the stack on a Unix OS?
I am running Arch Linux, 64bit latest update on one of my computers. I am currently a Computer Science student and we had a test yesterday where we were to implement a dynamic stack using linked lists....
1
vote
1
answer
9k
views
rhel 7 setting stack size to unlimited
I have some old code that needs the stack to not be limited to 8192kb in order for it to run.
I am used to doing this in /etc/security/limits.conf
* stack hard unlimited
* stack soft ...
3
votes
1
answer
1k
views
Unlimited stack size with pthreads
My default stack size (according to ulimit -s) is 8192 kB, so naturally the code below segfaults when I try to run it. Also, naturally, it works fine if I do a 'ulimit -s 9000'.
However, when I do a '...
0
votes
1
answer
45
views
Sequence of events and OS involvement when a process goes beyond its allocated stack
My understanding is that the Linux kernel allocates a stack to every process before it starts, and this initial size is configurable. A process can PUSH data to the stack directly via CPU instructions,...
0
votes
1
answer
97
views
Arbitrary code execution despite Data Execution Prevention
Nowadays with protections like W^X , is it still possible to successfully exploit buffer overflows with for example NOP Slide ?
5
votes
1
answer
293
views
Why does bash's tab completion trigger the stack protector?
I'm using bash 5.0.16 (and bash-completion 2.10) on Manjaro. Today, I absentmindedly hit the tab key while moving some files, and was greeted with an unexpected message:
[charles@wirepile some_dir]$ ...
2
votes
1
answer
596
views
Is it safe to use the .bss section as a static stack?
(This is in the context of x86-64 Linux.)
I am trying to write a high-reliability userland executable, and I have total control over the generated assembly. I don't want to rely on automatic stack ...
1
vote
1
answer
5k
views
How to view Stack Trace of a process?
I have seen this answer and according to that Stack Trace can be seen like:
$ cat /proc/<PID>/stack
[<ffffffff81012b72>] save_stack_trace_tsk+0x22/0x40
[<ffffffff81213abe>] ...
2
votes
1
answer
2k
views
What data structure is the stack using in Linux?
I have looked in several places such as here but none explain in detail the structs used for implementing the stack itself (the place where "tasks" (processes/threads) store their nested call ...
3
votes
1
answer
1k
views
Are stack canaries shared via threads?
As far as I understand, stack canaries work as fllows:
Upon program startup a random value is generated and stored
in the thread local storage (%fs:0x28). This random value is then pushed onto the ...
12
votes
2
answers
6k
views
How does the ELF loader determine the initial stack size?
I'm studying the ELF specification (http://www.skyfree.org/linux/references/ELF_Format.pdf), and one point that is not clear to me about the program loading process is how the stack is initialized, ...
1
vote
1
answer
778
views
AIX process stack watermark
Does exist any tool/command for checking the maximum that a process stack has used?
I need that to tune the stack size configuration for a program.
1
vote
1
answer
2k
views
How does Linux Kernel switches from kernel stack to interrupt stack?
What happens when a user mode task is interrupted ?
I know for a fact that the CPU switches to the kernel mode stack by refring the TSS.
But when and how does the kernel switches to the IRQ stack?
22
votes
2
answers
32k
views
Why on modern Linux, the default stack size is so huge - 8MB (even 10 on some distributions)
For example, on OSX, it's even less than 512k.
Is there any recommended size, having in mind, that the app does not use recursion and does not allocate a lot of stack variables?
I know the question ...
22
votes
2
answers
10k
views
What sets fs:[0x28] (stack canary)?
From this post it is shown that FS:[0x28] is a stack-canary. I'm generating that same code using GCC on this function,
void foo () {
char a[500] = {};
printf("%s", a);
}
Specifically, I'm ...
2
votes
1
answer
4k
views
pstack not printing stack output [closed]
I am running pstack to find function stack for my application running on two machines (both RHEL)
In one of my machine it is working as expected
[root@civ4cez191 bin]# pstack 22947
Thread 2 (Thread ...
3
votes
0
answers
669
views
How can I find the deepest and most stack-hungry call chains in a program?
I have a program written in OCaml that tends to stack-overflow on platforms with small stacks.
Rather than ulimiting the program to find and solve stack overflows one by one, I'd like to get a sorted ...
1
vote
1
answer
8k
views
GDB command to print the address of starting of buffer (stack)
For gdb debugger
(gdb) p &buffer
This command is used to print the content of starting of buffer (stack), or print the address?
If it is content, how to print the address?
-1
votes
2
answers
1k
views
fork() and execve() efficiency [closed]
In terms of memory allocation efficiency is it right to say that after a fork() in the code of the child if I execute a program with execve() this would be more efficient than the same program ...
4
votes
1
answer
9k
views
program stack size
I learned default stack size for each process is limited to 8MB and mmap_base is calculated based on stack size in rlimit and random value. Code below is mmap_base function which calculates mmap_base ...
0
votes
1
answer
1k
views
Top: DATA = RES + stack + what?
I've analyzed memory consumption of a java program on Linux Mint. I used top to capture memory statistics (memory used by program and also system-wide indicators like total_mem_used and mem_free). The ...
1
vote
1
answer
826
views
Could the stack be swapped to disk on Linux and can it be prevented
On Linux, is it possible that memory pages that contain the process stack get swapped to disk? If so, is there a way to prevent that, either at compile time or at runtime.
I'm asking because of a ...
4
votes
2
answers
2k
views
Memory Randomization in Linux
I created a simple C program and every time I load it in GDB, I see the same memory addresses allocated to the instructions of the program. For example, a function what() always loads at memory ...
1
vote
1
answer
1k
views
What is the relationship between the stack and the process table?
According to Wikipedia and many other sources,
Since PCB contains the critical information for the process, it must
be kept in an area of memory protected from normal user access. In
some ...
2
votes
1
answer
1k
views
Why must the stack VMA be executable?
I am currently reading Linux Kernel Development by Robert Love.
In the chapter "15 The Process Address Space" he prints the memory map of a process.
user@machine:~$ pmap 1424
#all the processes ...
1
vote
1
answer
152
views
Can you translate stack data? What is the data? [closed]
What I want to know is how is the data in a stack translated. We can see the data like: 0x80808080 but does it have a meaning?
What parts of the numbers stand for something different? And what does '...
1
vote
3
answers
156
views
bash - isolating uppercase words
So, I have a directory containing around 50 directories having for name 3 letter uppercase words:
AXC BCC EFC
amongst other directories.
I have already done a find to seek these 3 letter directories ...
2
votes
2
answers
864
views
Main stacks in Linux
What are the main stacks in Linux? What I mean is, for example when an interrupt occurs what stack will be used for it, and what is the difference between user process and kernel process stacks?
0
votes
1
answer
83
views
Match the three columns in 2 annotation files and print those lines to a new output file
I have 2 files, file 1 and file 2 with the same column numbers. Column one has the chromosome number, column two has the promoter start site and column three has the promoter stop site.
I want to ...
-1
votes
2
answers
204
views
First match if we are on the first line of input, if so print the whole line, else print the first word followed by a comma
for eg:
CREATE TABLE MWWDATA.ACK997 (
AKTYPE CHAR(2) DEFAULT '' NOT NULL ,
AKNUM CHAR(9) DEFAULT '' NOT NULL );
CREATE TABLE MWWDATA.APREIDEXC (
EMPLID NUMBER(15, 0) DEFAULT NULL );
I ...
0
votes
3
answers
139
views
i want to print the line which starts with a paricular word and in the rest records print only 1st field
for eg:
CREATE TABLE MWWDATA."VTCat02" (
"ID" NUMBER(10) DEFAULT NULL ,
"Cat" VARCHAR2(255) DEFAULT NULL ,
"Style_Code" VARCHAR2(255) DEFAULT NULL ,
"Vendor_Style_#" VARCHAR2(255) ...
0
votes
1
answer
583
views
I want to delete from particular words in all the line if that particular word is present
eg:
CREATE VIEW AIPKEYITEM.SEASONGROUPNETSALES (
CALENDARID ,
PRODUCTGROUPID FOR COLUMN PRDGRPID ,
NETSALESDOLLARS FOR COLUMN NETSA00001 ,
NETSALESUNITS FOR COLUMN NETSA00002 )
AS
SELECT
...
12
votes
1
answer
26k
views
How can I monitor per process/per thread memory consumption (divided into heap, stack, data, code)?
Before jumping in and writing my own code, I want to find out if there is GNU/Linux software that is able to output something similar to QNX's showmem.
For each thread of each process that is running,...
23
votes
3
answers
25k
views
How does stack allocation work in Linux?
Does the OS reserve the fixed amount of valid virtual space for stack or something else? Am I able to produce a stack overflow just by using big local variables?
I've wrote a small C program to test ...
2
votes
1
answer
4k
views
Ulimit unlimited stack behavior oddity
I am running an application on a Solaris 10 system.
Yesterday we have set the process stack size to unlimited:
ulimit -s unlimited
Today during the load the process would not come up reporting that ...