callstack

Node.js - Maximum call stack size exceeded

会有一股神秘感。 提交于 2019-11-26 04:36:56
问题 When I run my code, Node.js throws a \"RangeError: Maximum call stack size exceeded\" exception caused by too many recursive calls. I tried to increase Node.js stack size by sudo node --stack-size=16000 app , but Node.js crashes without any error message. When I run this again without sudo, then Node.js prints \'Segmentation fault: 11\' . Is there a possibility to solve this without removing my recursive calls? 回答1: You should wrap your recursive function call into a setTimeout , setImmediate

How to get the name of the calling class in Java?

二次信任 提交于 2019-11-26 02:58:35
问题 I would like some help on this matter, Example: public class A { private void foo() { //Who Invoked me } } public class B extends A { } public class C extends A { } public class D { C.foo(); } This is basically the scenario. My question is how can method foo() know who is calling it? EDIT : Basically I am trying to do a database Layer, and in Class A I will create a method that will generate SQL statements. Such statements are dynamically generated by getting the values of all the public

Are stack variables aligned by the GCC __attribute__((aligned(x)))?

只谈情不闲聊 提交于 2019-11-26 02:52:33
问题 i have the following code: #include <stdio.h> int main(void) { float a[4] __attribute__((aligned(0x1000))) = {1.0, 2.0, 3.0, 4.0}; printf(\"%p %p %p %p\\n\", &a[0], &a[1], &a[2], &a[3]); } And i have the following output: 0x7fffbfcd2da0 0x7fffbfcd2da4 0x7fffbfcd2da8 0x7fffbfcd2dac Why the address of a[0] is not a multiple of 0x1000 ? What exactly __attribute__((aligned(x))) does? I misunderstood this explanation? I\'m using gcc 4.1.2. 回答1: I believe the problem is that your array is on the

Array to pointer decay and passing multidimensional arrays to functions

梦想的初衷 提交于 2019-11-26 02:36:34
问题 I know that an array decays to a pointer, such that if one declared char things[8]; and then later on used things somewhere else, things is a pointer to the first element in the array. Also, from my understanding, if one declares char moreThings[8][8]; then moreThings is not of type pointer to char but of type \"array of pointers to char,\" because the decay only occurs once. When moreThings is passed to a function (say with prototype void doThings(char thingsGoHere[8][8]) what is actually

print call stack in C or C++

邮差的信 提交于 2019-11-26 01:02:39
Is there any way to dump the call stack in a running process in C or C++ every time a certain function is called? What I have in mind is something like this: void foo() { print_stack_trace(); // foo's body return } Where print_stack_trace works similarly to caller in Perl. Or something like this: int main (void) { // will print out debug info every time foo() is called register_stack_trace_function(foo); // etc... } where register_stack_trace_function puts some sort of internal breakpoint that will cause a stack trace to be printed whenever foo is called. Does anything like this exist in some

print call stack in C or C++

天大地大妈咪最大 提交于 2019-11-26 00:53:18
问题 Is there any way to dump the call stack in a running process in C or C++ every time a certain function is called? What I have in mind is something like this: void foo() { print_stack_trace(); // foo\'s body return } Where print_stack_trace works similarly to caller in Perl. Or something like this: int main (void) { // will print out debug info every time foo() is called register_stack_trace_function(foo); // etc... } where register_stack_trace_function puts some sort of internal breakpoint

What is the direction of stack growth in most modern systems?

你离开我真会死。 提交于 2019-11-26 00:46:13
问题 I am preparing some training materials in C and I want my examples to fit the typical stack model. What direction does a C stack grow in Linux, Windows, Mac OSX (PPC and x86), Solaris, and most recent Unixes? 回答1: Stack growth doesn't usually depend on the operating system itself, but on the processor it's running on. Solaris, for example, runs on x86 and SPARC. Mac OSX (as you mentioned) runs on PPC and x86. Linux runs on everything from my big honkin' System z at work to a puny little

How do you find out the caller function in JavaScript?

 ̄綄美尐妖づ 提交于 2019-11-25 23:57:39
问题 function main() { Hello(); } function Hello() { // How do you find out the caller function is \'main\'? } Is there a way to find out the call stack? 回答1: function Hello() { alert("caller is " + Hello.caller); } Note that this feature is non-standard , from Function.caller: Non-standard This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations

Why doesn&#39;t my program crash when I write past the end of an array?

 ̄綄美尐妖づ 提交于 2019-11-25 23:31:56
问题 Why does the code below work without any crash @ runtime ? And also the size is completely dependent on machine/platform/compiler!!. I can even give upto 200 in a 64-bit machine. how would a segmentation fault in main function get detected in the OS? int main(int argc, char* argv[]) { int arr[3]; arr[4] = 99; } Where does this buffer space come from? Is this the stack allocated to a process ? 回答1: Something I wrote sometime ago for education-purposes... Consider the following c-program: int q

Maximum call stack size exceeded error

会有一股神秘感。 提交于 2019-11-25 22:58:16
问题 I am using a Direct Web Remoting (DWR) JavaScript library file and am getting an error only in Safari (desktop and iPad) It says Maximum call stack size exceeded. What exactly does this error mean and does it stop processing completely? Also any fix for Safari browser (Actually on the iPad Safari , it says JS:execution exceeded timeout which I am assuming is the same call stack issue) 回答1: It means that somewhere in your code, you are calling a function which in turn calls another function