Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
179 views

I was reading an article on the Memory Layout of C Programs; https://www.geeksforgeeks.org/c/memory-layout-of-c-program/. It mentioned, under "4. Stack Segment": When the stack and heap ...
Supreeto's user avatar
  • 339
1 vote
2 answers
198 views

I am using an Ubuntu 16.04 a 32-bit Virtual Machine OS. I executed sysctl -w kernel.randomize_va_space=0 to disable ASLR in root prior to gcc. I have also compiled this using the command: gcc -g -fno-...
Wabba Fett's user avatar
17 votes
3 answers
1k views

I'm reading a GNU as introductory book for programs running on top of an OS. I'm at the stack memory part and I was curious how the stack looks like in a freestanding environment. I'm guessing that ...
mltm's user avatar
  • 605
2 votes
3 answers
267 views

I’m working on a C project where I need to know if a pointer refers to memory allocated on the stack or the heap. For example: int x = 42; // stack variable int *y = malloc(sizeof(...
Pawan Bhatta's user avatar
1 vote
1 answer
245 views

I've been messing around with assembly and compilers & have gotten a lot of conflicting information in how I should be using registers, the stack / spill over registers, and to what extent ...
Dak's user avatar
  • 51
1 vote
1 answer
61 views

I have disassembled a basic function into assembly language. The function is the 'main' function in a console application for Windows. It simply calls another function (named 'a') which does nothing, ...
chrisH's user avatar
  • 11
0 votes
1 answer
86 views

I want to understand how memory is allocated to function params in c. I compiled the same program twice with gcc -g except I interchanged the first and second params of a function on_menu for the ...
Groot's user avatar
  • 19
3 votes
0 answers
165 views

I have a fairly large UEFI application (2.1MB UPX compressed) that has a number of functions that allocate reasonably large data structures on the stack (kilobytes). I'd like to add some debug code ...
LimeyPgh's user avatar
1 vote
1 answer
90 views

Considering that the type A is defined like this: typedef struct a { const int a; } A; I know that this code is valid: A * foo = malloc(sizeof *foo); // Allocates uninitialized memory with no ...
Fayeure's user avatar
  • 1,483
1 vote
0 answers
77 views

I have a bit of C code for an ARM Cortex-M0 chip, for which I was investigating the disassembly: int func2(unsigned a) { int h[a]; for (unsigned i = 0; i < a; i++) { h[i] = 0; } int ch;...
Mark van der Wilk's user avatar
2 votes
0 answers
129 views

I know each segment in the executable file need to be aligned, before loaded into ram there were aligned to minimum page size of 4096 bytes and if there not enough fit within 4096 bytes they span ...
Nalan PandiKumar's user avatar
1 vote
1 answer
147 views

I want to understand if arr here is in stack or heap. Since obj is dynamically allocated is the arr in heap? What if i do not have obj2, if i just allocate obj dynamically in main? #include <...
Rich Gg's user avatar
  • 59
0 votes
0 answers
67 views

Are local variables always volatile in C#? In other words, is the volatility of num the same in these two classes: public sealed class ThreadSafeObjectA { private volatile int num; public int ...
user3163495's user avatar
  • 3,978
-1 votes
1 answer
111 views

How can I address elements on the stack that are not on top of it? I am talking about for instance first executing stmfd sp!, {r0-r12} and then push {lr}. Now I want to work with the first address of ...
user avatar
1 vote
4 answers
161 views

If each process has its own address space and it is much larger than the physical memory of the computer, why can’t we just place the stack at the end of this address space and the heap at the ...
omnit's user avatar
  • 13
1 vote
1 answer
688 views

I'm currently exploring stack frames and how they work in C programs, specifically on unprotected 32-bit x86 systems (no ASLR, stack canaries, or DEP). I'm not primarily a CS Student — I'm a physics ...
Jonas's user avatar
  • 11
1 vote
0 answers
103 views

I'm working on an assembler-disassembler tool in x64 assembly on Windows, and I'm encountering a strange issue related to function calls and stack alignment. The program is supposed to support basic ...
kavi castelo's user avatar
1 vote
0 answers
66 views

I've been messing around with assembly for a while and I found things which seems inconsistent. After some research I have some questions about stack / static (initialized/uninitialized) / heap memory....
Adam's user avatar
  • 11
1 vote
1 answer
75 views

I have a value on the stack, and I want to store it at a constant address in memory. Would the operation take the address from the stack first, I could put the address on the stack and store the value ...
matj1's user avatar
  • 344
0 votes
1 answer
104 views

The following question refers to x86 assembly, and little endianness. Suppose I have the following code in C: unsigned char myID[10] = "211866744"; How will this array be saved in memory? ...
David's user avatar
  • 63
-3 votes
1 answer
155 views

In C++ the size of an array must be determined at the compile-time. I want to write a simple code in C++, say, to do a naive matrix multiplication with itself (for a matrix that is square in size) and ...
MOON's user avatar
  • 2,871
2 votes
2 answers
143 views

I realized I never really thought of this. If I made a large enough recursive call chain, wouldn't the stack eventually grow down enough that it will overlap with other things, like shared libraries (...
natitati's user avatar
  • 167
0 votes
1 answer
265 views

In our Operating Systems class we mentioned virtual memory as a mechanism that abstracts physical memory to a process, and that it looks something like this (per process): The stack grows down the ...
lukascobbler's user avatar
5 votes
1 answer
454 views

According to Patterson & Hennessy's Computer Organization and Design (MIPS Edition), the stack pointer $sp is typically initialized to 0x7FFFFFFC. the stack pointer $sp is always pointing at the ...
Flandia Yingman's user avatar
0 votes
2 answers
134 views

if stack size is 1MB, does that mean i can only get less than 1000000/8 pointers to allocate ints in heap? (considering 1MB free stack) yeah i know you might not want to make that many individual ints ...
Nemexia's user avatar
  • 139
-1 votes
2 answers
314 views

I tried this quick-bench test and I'm finding that it's the same cost timewise to allocate 200 bytes as it is to allocate 2000000 bytes. How could that possibly be?
bobobobo's user avatar
  • 67.9k
0 votes
0 answers
47 views

I understanding the stack, the LIFO working principle, memory allocation on the heap and stuff. My question is, where does this exists ? Is there a dedicated region on the ram for the stack ? Or is it ...
Out Bruh's user avatar
0 votes
3 answers
516 views

I'm working on a core dump mechanism for STM32 mcus running FreeRTOS. I managed to extract the stack of the running tasks, and transmit it to a server where a python script writes it into a hex file. ...
KubbyDev's user avatar
0 votes
0 answers
95 views

This is a code to add all numbers between 50 and 150 and display the result in decimal form.I have created the stack segment .STACK 32 to store the remainders to convert the hex result to decimal ...
Bishal Lamichhane's user avatar
-4 votes
1 answer
100 views

typedef struct { double x; double y; } point; point p1; point* p2 = malloc(sizeof(point)); In this code where the variables p1,p2,p1.x, and p2->x are stored in stack or heap memory? Where ...
Suthekshan 's user avatar
0 votes
0 answers
53 views

The following snippet comes from the lesson 7 on asmtutor.com : ;------------------------------------------ ; void sprintLF(String message) ; String printing with line feed function sprintLF: call ...
vmonteco's user avatar
  • 15.9k
0 votes
1 answer
82 views

void foo() { int value = 0; char buf[4]; buf[4] = 1; printf("value: %d\n", value); } int main() { foo(); return 0; } Why does 'value' print 1? I believe this has to ...
miya's user avatar
  • 3
1 vote
1 answer
516 views

There doesn't seem to be any mention of a "Red Zone" for Aarch64 in the ABI, but Microsoft makes reference to a 16-byte red zone for Aarch64, Apple claims a 128-byte red zone in Writing ...
David C. Rankin's user avatar
0 votes
0 answers
29 views

I am currently learning assembly and I am trying to write a simple program. I have the following code: .global do_main .section .text do_main: sub $4, %esp movb $'H', (%esp) movb $'e', 1(%...
Alfa Hores's user avatar
-3 votes
1 answer
113 views

I have an abstract "x vs y" question. In C programming language if I have some small amount of data which I want to store somewhere in RAM, I suppose typical options are the next ones: to ...
Eimrine's user avatar
  • 61
0 votes
1 answer
141 views

I don't understand the logic of why the code results in stackOverFlow error: public class Human { private String name; private int age = 30; private Human human = new Human(); ...
NinaJava's user avatar
0 votes
0 answers
47 views

If I understand correctly, the RAM is virtually divided into stack and heap. Stack takes primitive types/functions etc and Heap deals with the reference types and objects. Stack follows the LIFO ...
Hopen's user avatar
  • 1
1 vote
1 answer
233 views

i have an enum where i have to perform pattern matching. But since i am running the program on VM which has limited stack memory ( < 4Kb ), i allocated the enum on the heap using Box. But while ...
Dhruv D Jain's user avatar
0 votes
0 answers
171 views

I am trying to allocate a new stack on the heap in C++ for a function using VirtualAlloc. While debugging, I noticed that the rsp value for my function can either increase or decrease relative to the ...
kliri's user avatar
  • 1
0 votes
0 answers
98 views

in my system (x86_64), when I'm using GDB, both RBP and RSP point to the same memory address after pushing a new stack frame, therefore I can't reference the end of the stack with the register RSP ...
strjak's user avatar
  • 15
1 vote
0 answers
500 views

I'm trying to build a recruitment management website (nodejs), but when I'm almost done I get this error: Uncaught RangeError: Maximum call stack size exceeded. functionjs.js Here is my functionjs.js ...
Cmint's user avatar
  • 19
2 votes
2 answers
148 views

Runge-Kutta schemes consist of an algorithm, implemented in Scheme, and a piece of data, called Table (Butcher tableau). For the construction of a scheme, we want consumers to use the syntax Scheme s =...
GRamon's user avatar
  • 87
1 vote
0 answers
43 views

I'm debugging a program that has many alloca and triggers EXC_BAD_ACCESS (with -msanitize=address) or crashes __chkstk_darwin (without compiler sanitizer). I want to know the valid stack address range ...
jiandingzhe's user avatar
  • 2,185
0 votes
3 answers
109 views

At the moment I am messing around a little bit with Sorting Algorithms in C. In the course of this I have run into the following problem: I have defined an int array with int array[LENGTH]; where ...
LeChummpy's user avatar
3 votes
2 answers
120 views

I'm using an array of functions pointers, and I'd like to use it directly with their associated event IDs. Problem is, event IDs start from 0x10 to 0x1C, and from 0x90 to 0xA5. I don't want to write ...
mescande's user avatar
1 vote
2 answers
613 views

I am bit confused about the stack and heap memory of STM32 microcontrolers (cortex M0). Firstly, they are part of RAM, but are they part of RAM size described in the datasheet ? Secondly, if I reduce ...
NinjaGreg's user avatar
-1 votes
1 answer
315 views

For context, this was taken from an excerpt in a book: Finally, sometimes you can't even use heap memory! If you are programming in Rust for a small embedded device, you are going to have to use only ...
Dainank's user avatar
  • 2,613
0 votes
1 answer
195 views

I have been given this code in C and I need to calculate the bytes allocated to the stack frame of function arith. I looked everywhere for a way to do it but everyone has a different answer. long ...
Zayed Aldhaheri's user avatar
0 votes
0 answers
103 views

rephrased the question Getting segmentation fault right after last printf after iterating and displaying stack values (2 iterations for simplicity purposes). Just trying to display hex value on the ...
T-series's user avatar
0 votes
1 answer
392 views

I'm looking to understand the organization of memory in my programming language, which consists of four primary areas: stack, heap, code, and data. However, I'm unclear about where the programming ...
Hassan Lakhal's user avatar

1
2 3 4 5
22