Home > other >  Why does declaring a 2D array of sufficient size cause a segfault on Linux but not macOS?
Why does declaring a 2D array of sufficient size cause a segfault on Linux but not macOS?

Time:01-11

Problem

I'm trying to declare a large 2D Array (a.k.a. matrix) in C / C , but it's crashing with segfault only on Linux. The Linux system has much more RAM installed than the macOS laptop, yet it only crashes on the Linux system.

My question is: Why does this crash only on Linux, but not macOS?

Here is a small program to reproduce the issue:

// C   program to segfault on linux
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    cout << "Let's crash for no raisin!            
  •  Tags:  
  • Related