Gmaps4rails Maximum call stack size exceeded? - ruby-on-rails

I've got the following setup, what I want to do is update the markers when a map is moved:
https://gist.github.com/277894809fe04cbc29c7
The json endpoint returns for example:
[{"_id":"4ecc19ca8de17b2f0f000001","latitude":47.413358,"location":[47.413358,9.744583],"longitude":9.744583,"name":"d2"},{"_id":"4ecc14e68de17b2924000001","latitude":47.413417,"location":[47.413417,9.744417],"longitude":9.744417,"name":"another"}]
but I get the following error when moving the map:
Uncaught RangeError: Maximum call stack size exceeded
I.get
a.(anonymous function)
tB.(anonymous function).zoomRange_changed
mf
I.set
(anonymous function)
tB.(anonymous function).zoomRange_changed
mf
I.set
......
No idea what causes this, I put together the sample from various sources, had to adapt a lot as it seems the methods etc changed a lot.
Not sure if I missed something, I would be glad if someone could give me a pointer
Thanks a lot,
Christoph

In your json, you should replace: longitude with lng and latitude with lat.
But I should change the code to avoid this kind of weird surprises when arguments are malformed.

It looks like that you have endless recursion in method I.set.

Related

Pinescript code give "no data" on tradingview or gives cant find a certain function error

this is quite new to me, so I've been trying to make it work for the past few days, but keep getting errors.
I'm trying to create a strategy code for several indicator, but get "Could not find function or function reference 'sma'" error or it compiles perfectly but get no data on the overview pane...
I decided to try the most basic code to see what happens:
strategy("Simple Moving Average Strategy", overlay=true)
// Define the moving average
ma = sma(close, 20)
// Buy signal
strategy.entry("Buy", strategy.long, when=crossover(close, ma))
// Sell signal
strategy.exit("Sell", when=crossunder(close, ma))
This yields no data.
can someone please assist?
also, if you guys can explain why I get "Could not find function or function reference 'sma'" (or other functions) eventhough the rest of the code is just fine, that would be great.
Thanks!
Tried reducing the code to its basics, to pinpoint the error.

Where does a segmentation fault occur if the debugger points to a function definition?

To elaborate, I am currently writing a program that requires a function that is provided by the professor. When I run the program, I get a segmentation fault, and the debugger I use (gdb) says that the segmentation fault occurred at the definition of the function that, like I said, was provided by the professor.
So my question here is, is the definition itself causing the fault, or is it somewhere else in the program that called the function causing the fault?
I attempted to find a spot in the program that might have been leading to it, such as areas that might have incorrect parameters. I have not changed the function itself, as it is not supposed to be modified (as per instructions). This is my first time posting a question, so if there is any other information needed, please let me know.
The error thrown is as follows:
Program received signal SIGSEGV, Segmentation fault. .0x00401450 in Parser::GetNextToken (in=..., line=#0x63fef0: 1) at PA2.cpp:20 20 return GetNextToken(in, line);
The code itself that this is happening at is this:
static LexItem GetNextToken(istream& in, int& line) {
if( pushed_back ) {
pushed_back = false;
return pushed_token;
}
return GetNextToken(in, line);
}
Making many assumptions here, but maybe the lesson is to understand how the stack is affected by a function call and parameters. Create a main() function, that call the professor's provided function and trace the code using dbg, looking at the stack.

CommRenderer cannot cope with an absent value in commUser.getPosition()

The documentation of commUser.getPosition() advices to return Optional.absent() if no position can be determined. Yet, lines 170 in CommRenderer throws an exception if commUser.getPosition() is absent:
helper.fillCircle(user.getPosition().get(), DOT_RADIUS);
The method exampleCommunicationAgent.getPosition() returns absence, if RoadUser is not on roadmap - which happens sometimes, but I cannot pinpoint when exactly. It might have something to do with increasing the speed, but I can't reproduce it reliably.
This bug is fixed as of RinSim 4.4.5.

Passing Data through the Stack

I wanted to see if you could pass struct through the stack and I manage to get a local var from a void function in another void function.
Do you guys thinks there is any use to that and is there any chance you can get corrupted data between the two function call ?
Here's the Code in C (I know it's dirty)
#include <stdio.h>
typedef struct pouet
{
int a,b,c;
char d;
char * e;
}Pouet;
void test1()
{
Pouet p1;
p1.a = 1;
p1.b = 2;
p1.c = 3;
p1.d = 'a';
p1.e = "1234567890";
printf("Declared struct : %d %d %d %c \'%s\'\n", p1.a, p1.b, p1.c, p1.d, p1.e);
}
void test2()
{
Pouet p2;
printf("Element of struct undeclared : %d %d %d %c \'%s\'\n", p2.a, p2.b, p2.c, p2.d, p2.e);
p2.a++;
}
int main()
{
test1();
test2();
test2();
return 0;
}
Output is :
Declared struct : 1 2 3 a '1234567890'
Element of struct undeclared : 1 2 3 a '1234567890'
Element of struct undeclared : 2 2 3 a '1234567890'
Contrary to the opinion of the majority, I think it can work out in most of the cases (not that you should rely on it, though).
Let's check it out. First you call test1, and it gets a new stack frame: the stack pointer which signifies the top of the stack goes up. On that stack frame, besides other things, memory for your struct (exactly the size of sizeof(struct pouet)) is reserved and then initialized. What happens when test1 returns? Does its stack frame, along with your memory, get destroyed?
Quite the opposite. It stays on the stack. However, the stack pointer drops below it, back into the calling function. You see, this is quite a simple operation, it's just a matter of changing the stack pointer's value. I doubt there is any technology that clears a stack frame when it is disposed. It's just too costy a thing to do!
What happens then? Well, you call test2. All it stores on the stack is just another instance of struct pouet, which means that its stack frame will most probably be exactly the same size as that of test1. This also means that test2 will reserve the memory that previously contained your initialized struct pouet for its own variable Pouet p2, since both variables should most probably have the same positions relative to the beginning of the stack frame. Which in turn means that it will be initialized to the same value.
However, this setup is not something to be relied upon. Even with concerns about non-standartized behaviour aside, it's bound to be broken by something as simple as a call to a different function between the calls to test1 and test2, or test1 and test2 having stack frames of different sizes.
Also, you should take compiler optimizations into account, which could break things too. However, the more similar your functions are, the less chances there are that they will receive different optimization treatment.
Of course there's a chance you can get corrupted data; you're using undefined behavior.
What you have is undefined behavior.
printf("Element of struct undeclared : %d %d %d %c \'%s\'\n", p2.a, p2.b, p2.c, p2.d, p2.e);
The scope of the variable p2 is local to function test2() and as soon as you exit the function the variable is no more valid.
You are accessing uninitialized variables which will lead to undefined behavior.
The output what you see is not guaranteed at all times and on all platforms. So you need to get rid of the undefined behavior in your code.
The data may or may not appear in test2. It depends on exactly how the program was compiled. It's more likely to work in a toy example like yours than in a real program, and it's more likely to work if you turn off compiler optimizations.
The language definition says that the local variable ceases to exist at the end of the function. Attempting to read the address where you think it was stored may or may produce a result; it could even crash the program, or make it execute some completely unexpected code. It's undefined behavior.
For example, the compiler might decide to put a variable in registers in one function but not in the other, breaking the alignment of variables on the stack. It can even do that with a big struct, splitting it into several registers and some stack — as long as you don't take the address of the struct it doesn't need to exist as an addressable chunk of memory. The compiler might write a stack canary on top of one of the variables. These are just possibilities at the top of my head.
C lets you see a lot behind the scenes. A lot of what you see behind the scenes can completely change from one production compilation or run to the next.
Understanding what's going on here is useful as a debugging skill, to understand where values that you see in a debugger might be coming from. As a programming technique, this is useless since you aren't making the computer accomplish any particular result.
Just because this works for one compiler doesn't mean that it will for all. How uninitialized variables are handled is undefined and one computer could very well init pointers to null etc without breaking any rules.
So don't do this or rely on it. I have actually seen code that depended on functionality in mysql that was a bug. When that was fixed in later versions the program stopped working. My thoughts about the designer of that system I'll keep to myself.
In short, never rely on functionality that is not defined. If you knowingly use it for a specific function and you are prepared that an update to the compiler etc can break it and you keep an eye out for this at all times it might be something you could explain and live with. But most of the time this is far from a good idea.

Simperium - Diff errors, UniCharMax

I'm serializing an array of dictionaries to a string and it seems that it causes issues on the generation of the diff… or something… I've been seeing a lot of these:
AssertMacros: hash <= (~(UniChar)0x00), Hash value has exceeded UniCharMax! file: /Users/…/Pods/Google-Diff-Match-Patch/DiffMatchPatchCFUtilities.c, line: 391
I didn't look very deep but I didn't understood what am I doing wrong…
Also, I'm having a lot of 440 errors that sometimes appear with the error above. How can I handle these errors? Shouldn't the framework send the full object when the 440 pops up?
Thanks!
Error 440 means 'Invalid Diff'. After checking DiffMatchPatch, it seems that the error you're seeing is caused by an excesively large array of diffs (which, in this case, seems to be a Diff Match Patch internal issue).
Please, take a look at this pull request, which already implements the mechanism you're currently working on: https://github.com/Simperium/simperium-ios/pull/121
Specifically, NSArray+Simperium, SPMemberJsonList and SPJsonDiff contain logic to handle DiffMatchPatch.

Resources