I don’t know what happens with me when it comes to the segment trees, i always fucked up with the tree size. the result is a stupid SIGSEGV.
So the rule of thumb when dealing with the segment tree problem is to be careful with it’s size. (pow(2, ceil(log2(n)) + 1))
and in these cases valgrind, gdb comes in great help to recognize where the memory leaks are occurring.