stack

Sleep() inline assembly call works but generates runtime check-failure

强颜欢笑 提交于 2019-12-12 01:36:44
问题 As the title of my question says the sleep() function works properly (and every other function call in the C function, the problem is that after it's finished running I get an error that says: "Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention." I believe the way I'm handling the registers when I call

Python: sys.excepthook and logging uncaught exceptions across multiple modules

旧城冷巷雨未停 提交于 2019-12-12 01:09:40
问题 In all of my Python main scripts and modules, I have been trying to implement a way to log uncaught exceptions to the module in which the exception was thrown's logger. I'm doing this the same way in all of my files: def log_unhandled_exception(*exc_info): text = "".join(traceback.format_exception(*exc_info)) logger.critical("An unhandled exception has caused this script to terminate prematurely. Here are the details: {0}".format(text)) sys.exit(2) def some_function(): # ... sys.excepthook =

swapping the first and last element in a stack using c++

▼魔方 西西 提交于 2019-12-11 23:33:53
问题 i want to make a function to take a stack (as array) and for it to return the stack swapping the first element with the last element in the Stack so i'll use a temp stack for the data and i'll use but how will i know when will i reach the end of the stack ? i've wrote the implementation of stack as an array but i need help with the function swap void Swap(Stack x) { Stack tmp(100); int top1 = x.pop; for (int i = 0;; i++) { x.pop = tmp.push; } } i know its wrong but i'm not sure any help would

Debugging C program (int declaration)

余生长醉 提交于 2019-12-11 19:29:16
问题 I'm still learning assembly and C, but now, I'm trying to understand how the compiler works. I have here a simple code: int sub() { return 0xBEEF; } main() { int a=10; sub(); } Now I know already how the CPU works, jumping into the frames and subroutines etc. What i don't understand is where the program "store" their local variables. In this case in the main's frame? Here is the main frame on debugger: 0x080483f6 <+0>: push %ebp 0x080483f7 <+1>: mov %esp,%ebp 0x080483f9 <+3>: sub $0x10,%esp =

Set Java call stack

一曲冷凌霜 提交于 2019-12-11 19:28:24
问题 is it possible to modify/access the Java call stack ? For instance saving and restoring ? I'm thinking about implementing cooperative multitaskting (especially I/O) just like gevent for python or haskell (which does this natively). The async callback spaghetti mess can't be the best solution. 回答1: The simplest solution is to have multiple threads. You can have up to 10,000 threads running efficiently on a server. If you need much more than this, I would suggest either a) buying a second

Class method access to it's data members

江枫思渺然 提交于 2019-12-11 19:04:45
问题 I would use a small code to explain my question: class C { int a; public: func() { a = 4; }; }; int main() { C obj1; obj1.func(); return 0; } Here func() method tries to set a (a data member of obj1 ) to a value of 4. How does func() get access to a ? Is it because func() has access to this* for obj1 ? If that's true, how does func() get access to this* ? Is it passed to func() as an implicit argument while calling obj1.func() from main() ? If it's passed as an argument, does main() stack

How is a stack belonging to a thread different from a stack of a process

流过昼夜 提交于 2019-12-11 18:30:03
问题 Can anybody please tell me what is the difference b/w the two types of stacks. If I see /proc/<pid>/map and proc/pid/task/<tid> I see same map. Is there a way we can see the stack belonging to thread exclusively (I mean not the stack of process thread) or if there is any gdb command to find out thread specific stack. Thanks, Kapil 回答1: Is there a way we can see the stack belonging to thread exclusively There is no such thing: all the threads share the entire address space, so the stack doesn

Segmentation Fault error - Implementing Stack using Linked lists

和自甴很熟 提交于 2019-12-11 18:09:22
问题 I am currently in a University program studying Data Structures in C and I am having a lot of trouble right now. I want to make clear that what I am asking help for is not for marks, just practice challenge problems. The goal is to implement a stack using Linked Lists. By looking through the lecture notes I think I have most of the functions down. I need to demonstrate Push() and Pop() will an append and a pretend. Using Cygwin, I compiled with no errors. but when I try to run it, I get a

C++ standard terminology for heap/stack [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 17:36:18
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . There seems to be some uncertainty about the terminology that should be used. There seems to be 2 different points of view: some

Reduce stacktrace of executing frame

倾然丶 夕夏残阳落幕 提交于 2019-12-11 16:47:56
问题 I'm doing my best to not be vague here and this all could be solved with a while loop, but as an exercise I've gone against the best practice of using a while loop in hopes to learn something new. I'm re-learning some basics of CPU architecture, and thought it'd be a fun project to implement CPU emulation with "actual" JMP logic, or as close to it as possible in software. However, I'm getting stuck on a rendering process of said logic. The code is (according to my best judgement) irrelevant