Timer Interrupt stop working after malloc

I am using the FreeRTOS V7.4.2 with ARM-CM3 port (NXP LPC1788) and GCC cross compiler. Below is a pseudo code to reproduce my trouble:
void main()
{
  setup_timer1_with_interrupt_1ms();
  /*   when the two below lines are commented, all works fine */
  char *p = pvPortMalloc(16);
  if (p) turn_on_led2();
  while(1);
  
  the_function();

  // task creations and other setups
  vTaskStartScheduler();
}
void timer1_handler(void)
{
  count_until_500_and_toggle_led1();
}
When I run this piece of code the led1 don’t blink and the led2 turn on, but when I comment the malloc line the led1 blink, so, the Time1 interrupt stop working after allocate memory. I knew that malloc disable/re-enable the interrupts, so, Is possible that re-enable is not restoring the interrupts properly?

Timer Interrupt stop working after malloc

I noticed that after the scheduler is started the interrupt works properly. Is not possible use the interrupts while the scheduler is not running, even with timer priority out of configMAX_SYSCALL_INTERRUPT_PRIORITY range?

Timer Interrupt stop working after malloc

We always recommend leaving interrupts disabled until the scheduler has started, and, as your found out, if you call certain (most) API functions before the scheduler has started then interrupts will be left masked when the API function exits.  Interrupts will automatically be enabled when the scheduler starts. However, I would only expect interrupts below configMAX_SYSCALL_INTERRUPT_PRIORITY to be masked. Regards.

Timer Interrupt stop working after malloc

Thanks for your reply Richard. My timer1 interrupt don’t use FreeRTOS API. I found a post with exact same situation that I am facing: http://www.embeddedrelated.com/groups/AT91SAM/show/4236.php, and I guess that solution response it’s yours. My Makefile use -mthumb for all sources files, but I gotten a error when I tried use the -marm flag in gcc (target CPU does not support ARM mode).  And the -mthumb-interwork flag, build fine, but don’t work too. Regards