ESP32 CONFIG_ESP_SYSTEM_PANIC_HALT set still causes reboot

I don’t know if this question is a duplicate, but I am having issues trying to set the CONFIG_ESP_SYSTEM_PANIC_HALT option in my build_flags. When I tried to run my code here:

#ifdef CONFIG_ESP_SYSTEM_PANIC_HALT

#warning "using CONFIG_ESP_SYSTEM_PANIC_HALT option"

#endif

#ifdef CONFIG_ESP_SYSTEM_PANIC_REBOOT

#warning "using CONFIG_ESP_SYSTEM_PANIC_REBOOT option"

#endif

Only the first warning was printed. But when I encountered an abort() statement, the board printed the backtrace and rebooted immediately. Is there a problem with how I am setting the config?

Here is my platformio.ini file:

[env]
platform = espressif32
board = esp32doit-devkit-v1
monitor_raw = yes
monitor_speed = 115200
framework = arduino
build_flags = 
    -DCORE_DEBUG_LEVEL=3
    -DCONFIG_ESP_SYSTEM_PANIC_HALT=y
    -DCONFIG_ESP_SYSTEM_PANIC_REBOOT=n
    -DCONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID

build_unflags = 
    -DCONFIG_ESP_SYSTEM_PANIC_REBOOT

// Other envs

Since the Arduino-ESP32 framework uses a precompiled version of ESP-IDF by default, you cannot change any ESP-IDF CONFIG_.. defines in your project. They have no effect, since ESP-IDF is not recompiled with these new flags.

If you need your ESP32 Arduino project to use different ESP-IDF flags, use the special framework = arduino, espidf option, which compiles ESP-IDF from source, allowing you to change options freely.

See

and the documentation

https://docs.platformio.org/en/stable/frameworks/espidf.html