A stack overflow has been detected.

I'm getting a stack overflow runtime exception when I declare my struct json_schema_sync_response_t. I've included the full definition below. I don't understand why I'm getting this error. Could someone please help me out? I've reduced it to the line with the comment besides it. Thanks!

#ifndef HTTP_JSON_SCHEMAS_H
#define HTTP_JSON_SCHEMAS_H

#include <string>
#include <array>

typedef struct json_schema_device_t json_schema_device_t;
typedef struct json_schema_zone_t json_schema_zone_t;
typedef struct json_schema_region_t json_schema_region_t;
typedef struct json_schema_sync_response_t json_schema_sync_response_t;

// https://stackoverflow.com/questions/888386/resolve-circular-typedef-dependency

struct json_schema_device_t {
  int id;
  std::string macAddress;
};

struct json_schema_zone_t {
  int deviceCount = 0;
  std::array<json_schema_device_t, 20> devices;  // this produces a stack overflow on declaration
};

struct json_schema_region_t {
  int zoneCount = 0;
  std::array<json_schema_zone_t, 14> zones;

  int deviceCount = 0;
  std::array<json_schema_device_t, 20> devices;
};

struct json_schema_sync_response_t {
  bool success;
  
  std::string gatewayToken;

  int regionCount = 0;
  std::array<json_schema_region_t, 5> regions;
};

#endif

Does it work with 19? Does it work with 2?

Which Arduino and have you looked at how much memory it has?

Are you using the not-yet-released Arduino with 2 terabytes of memory? Your coding approach certainly makes it appear that you have no concept of how much memory you have to work with.

MorganS:
Which Arduino and have you looked at how much memory it has?

ESP32 WROVER with 4MB PSRAM. Shortly after posting, I realized I was barking up the wrong tree... I was thinking it was a declaration issue not an actual stack allocation issue (despite the error message). I have 4MB of RAM, so I figured it'd be ok.

PaulS:
Are you using the not-yet-released Arduino with 2 terabytes of memory? Your coding approach certainly makes it appear that you have no concept of how much memory you have to work with.

A bit extreme answer, but I get the gist of it. Thanks for the help! I ended up using a std::vector (pooled) since the number of items can really vary (1 to 3 regions... 1 to 10 devices, etc.). I'll just put the chip to sleep after HTTP anyways.