Skip to content

stl::unordered_map insert() causes abort() when out-of-memory #2827

@zoliweiss

Description

@zoliweiss

Hardware:

Board: ESP32 DoIt module - Chip is ESP32D0WDQ6 (revision 1)
Core Installation version: 1.0.2-rc1
IDE name: Arduino IDE 1.8.5
Flash Frequency: 80Mhz
PSRAM enabled: IDK
Upload Speed: 921600
Computer OS: Win 7

Description:

When I insert too much entries into unordered_map container, the ESP32 suddenly reboots. Should be throwing bad_alloc exception. I tried catching (...) also. Exception decoder can't decode anything. I am not sure if this is an ESP32/GCC/... problem.

The code:

  std::unordered_map<int, std::string> l_map;

  for(int i = 0; i < 100000; i++)
  {
    printf("%d\n", i);

    try
    {
      auto l_result = l_map.insert({i, std::to_string(i)});

      std::cout << l_result.second << std::endl;
    }
    catch(const std::bad_alloc&)
    {
      printf("OOOOOPS\n");
    }
  }

Debug Messages:

1
5378
1
5379
1
5380
1
5381
abort() was called at PC 0x400f594f on core 1

Backtrace: 0x4008b384:0x3ffb1e40 0x4008b5b5:0x3ffb1e60 0x400f594f:0x3ffb1e80 0x400f5996:0x3ffb1ea0 0x400f5b71:0x3ffb1ec0 0x400e6140:0x3ffb1ee0 0x400d18aa:0x3ffb1f00 0x400d1986:0x3ffb1f30 0x40100eab:0x3ffb1fb0 0x4008765d:0x3ffb1fd0

Rebooting...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions