c - Proc crashes even if it allocates less memory than limited by ulimit -


i have set stack size 2000kb ulimit -s 2000 , ulimit -ss 2000 hard limit. , in below program have allocated appox 2040000(510000 x 4) bytes less limited i.e,. 2048000(2000*4)bytes see program crashes! can suggest why happens.

#include <stdio.h> #include <malloc.h> int main() {     int a[510000] = {0};     a[510000] = 1;     printf("%d", a[510000]);     fflush(stdout);     sleep(70); } 

edit 1: crash not because of array index out of bound tried lower index , still crashes. happens when limit ulimit.

int a[510000] array index 0 509999. a[510000] outside array range.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -