Code execution never finished from R_ICU_ExternalIrqEnable() or memset()

Hello,

I'm working on a project uses RA6M5 MCU. FSP version is 3.5.0. IAR is 9.10.2.

I'm having a weird issue. I have an external IRQ. When running in debug mode in IAR, the R_ICU_ExternalIrqEnable() will call R_BSP_IrqEnableNoClear() eventually. But the code execution never finished from R_BSP_IrqEnableNoClear() - the debugging hanging in IAR, no further code execution possible. Here is the code:

icu_instance_ctrl_t g_external_ctrl;
const external_irq_cfg_t g_external_cfg =
{
  .channel       = 14,
  .trigger       = EXTERNAL_IRQ_TRIG_LEVEL_LOW,
  .filter_enable = true,
  .pclk_div      = EXTERNAL_IRQ_PCLK_DIV_BY_64,
  .p_callback    = my_isr,
  .p_context     = NULL,
  .p_extend      = NULL,
  .ipl           = (12),
  .irq           = VECTOR_NUMBER_ICU_IRQ,  // = ((IRQn_Type) 32)
};

typedef struct _my_control {
  uint16_t var1;
  uint16_t var2;
  uint16_t var3;
  uint16_t var4;
} my_control_t;

my_control_t g_control;

void func_ext_irq(void)
{
  fsp_err_t err = FSP_SUCCESS;

  err = R_ICU_ExternalIrqOpen(&g_external_ctrl, &g_external_cfg);
  if (FSP_SUCCESS != err)
  {
    return;
  }

  err = R_ICU_ExternalIrqEnable(&g_external_ctrl);
  if (FSP_SUCCESS != err)
  {
    return;
  }
}

// bsp_irq.h
__STATIC_INLINE void R_BSP_IrqEnableNoClear (IRQn_Type const irq)
{
    /* The following statement is used in place of NVIC_EnableIRQ to avoid including a branch for system exceptions
     * every time an interrupt is enabled in the NVIC. */
    uint32_t _irq = (uint32_t) irq;
    NVIC->ISER[(((uint32_t) irq) >> 5UL)] = (uint32_t) (1UL << (_irq & 0x1FUL));  // <-- The execution never finished
}

void func_other()
{
  . . .
  func_ext_irq();
  memset(&g_control, 0, sizeof(g_control));
  . . .
}

Later, I commented out the R_ICU_ExternalIrqEnable() line. But the execution doesn't return from memset() which is a simple function. Here is the code:

void func_ext_irq(void)
{
  fsp_err_t err = FSP_SUCCESS;

  err = R_ICU_ExternalIrqOpen(&g_external_ctrl, &g_external_cfg);
  if (FSP_SUCCESS != err)
  {
    return;
  }

  //err = R_ICU_ExternalIrqEnable(&g_external_ctrl);
  //if (FSP_SUCCESS != err)
  //{
  //  return;
  //}
}

void func_other()
{
  . . .
  func_ext_irq();
  memset(&g_control, 0, sizeof(g_control));  // <-- The execution never finished
  . . .
}

I'm not sure what went wrong. There is no complain about the memory shortage. Is there any way to find out what went wrong with the above code? Is it something to do with the stack or program counter?

Thanks!