stack

How to debug 'value of ESP was not saved across function call' error?

十年热恋 提交于 2019-12-24 05:12:16
问题 On rare occasions when my program exits, I get a "value of ESP has not been saved across a function call" error. The error is quite random and hard to reproduce. How do I debug this error (VC++ 2008)? How harsh it is, as it only occurs on shutdown? Is the error visible also in release mode? 回答1: This means that either you call a function with a wrong calling convention - that often happens when you declare a function pointer improperly - or there's something overwriting the stack. To debug

In x86 assembly, is ESP decremented twice after a call and then push, before data is saved on the stack?

▼魔方 西西 提交于 2019-12-24 05:01:36
问题 Long story short, I'm studying a book titled "The 8088 and 8086 Microprocessors" by Singh and Triebel, to learn old assembly for those specific CPUs. Now, the computer I'm practicing on is my main computer, which I recently built, so the registers are bigger. That said, the book (which I find extremely helpful) says that the call label operand causes the address of the instruction following the call to be placed on the stack, and THEN SP is decremented by 2 ( ESP , and decremented by 4 on my

Declared variables stack

冷暖自知 提交于 2019-12-24 03:34:56
问题 I have 2 files name auth_overflow & auth_overflow2, the only difference is the sequence of the variable declaration. My question is, does declaration sequence affect their stack sequence according to FILO (first in last out)? auth_overflow bash-4.2$ gdb -q auth_overflow Reading symbols from /home/reader/hacking/auth_overflow...done. (gdb) list 5 int check_authetication (char *password) { 6 int auth_flag = 0; 7 char password_buffer[16]; 8 9 strcpy(password_buffer, password); (gdb) break 9

Assembly Language Absolute addresses and segment registers

梦想与她 提交于 2019-12-24 02:51:36
问题 a review problem lists these registers in hex: cs = ???? sp = 0300 ax = a66a ip = 01cf ds = 4100 bp = 0003 bx = 1234 ss = 48ee si = 0100 cx = 00ff es = 4cee di = 1000 dx = 0000 The absolute address of the next instruction to be executed is 40f0f. 40f0f -01cf _____ 40d40 / 10 = 40d4 = cs Is the size of the data segment in bytes always equal to the stack segment minus the data segment * 10? 48ee - 4100 = 7ee0. Likewise, is the code segment in bytes always equal to the data segment minus the

GDB ret “cannot access memory at address”

落花浮王杯 提交于 2019-12-24 02:39:07
问题 Put simply: top of stack ($esp) = 0xbffff49c . gdb executes ret instruction, which responds with Cannot access memory at address 0x90909094 . What reason would gdb be trying to access 0x90909094 when the value at the top of the stack is 0xbffff49c ? Random info (in case it's needed): [----------------------------------registers-----------------------------------] EAX: 0x5a ('Z') EBX: 0xb7fbeff4 --> 0x15ed7c ECX: 0xbffff428 --> 0xb7fbf4e0 --> 0xfbad2a84 EDX: 0xb7fc0360 --> 0x0 ESI: 0x0 EDI:

infix to postfix in java using stack class

寵の児 提交于 2019-12-24 02:30:32
问题 I'm trying to write infix to postfix program in java using stack. Here is my code: import java.io.*; import java.util.*; public class ONP{ public static void main(String args[]) throws java.io.IOException, NumberFormatException ,EmptyStackException{ BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); StringBuilder out= new StringBuilder(); Stack st=new Stack(); for(int i=0;i<n;i++){ String input=br.readLine(); char in[]=input

OCaml Stack of tuples

放肆的年华 提交于 2019-12-24 02:23:28
问题 I am trying to create a stack of tuples in OCaml using the following piece of code let (k : (string*string) Stack.t) = Stack.create ;; But when doing so i get an error while compiling telling Error: This expression has type unit -> 'a Stack.t but an expression was expected of type (string * string) Stack.t Am pretty new to OCaml. Can someone point out where I am going wrong? 回答1: Stack.create is a function which takes the value () (of type unit ) and give you back a stack. So you should do:

OCaml Stack of tuples

女生的网名这么多〃 提交于 2019-12-24 02:23:05
问题 I am trying to create a stack of tuples in OCaml using the following piece of code let (k : (string*string) Stack.t) = Stack.create ;; But when doing so i get an error while compiling telling Error: This expression has type unit -> 'a Stack.t but an expression was expected of type (string * string) Stack.t Am pretty new to OCaml. Can someone point out where I am going wrong? 回答1: Stack.create is a function which takes the value () (of type unit ) and give you back a stack. So you should do:

Getting wrong outputs in infix to postfix application with java

寵の児 提交于 2019-12-24 02:13:44
问题 i recently wrote a java program that takes an infix expression and converts it into a postfix expression. It works for the most part but i am getting wrong outputs for some expressions. For example the expression a+b+c+d+e will output abcde+++++ when it should output a b + c + d + e +. import java.util.Stack; public class ITP { public static Stack<Character> stack; public static String inFixExp; public static String postFixExp = ""; public static String infixToPostfix(String exp){ ITP o = new

how to reference local variables on the stack properly

送分小仙女□ 提交于 2019-12-24 01:45:22
问题 Enter in function, standard prologue push rbp mov rbp, rsp sub rsp, 128 ; large space for storing doubles, for example How to reference local variables now, via rsp + positive offset, or via rbp + negative offset? Reading https://en.wikibooks.org/wiki/X86_Disassembly/Functions_and_Stack_Frames, indeed quite understandable. It writes ...the value of esp cannot be reliably used to determine (using the appropriate offset) the memory location of a specific local variable. To solve this problem,