chPoolAlloc fails system state check

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

elasticdoor
Posts: 8
Joined: Sun Nov 14, 2021 8:44 pm
Has thanked: 2 times
Been thanked: 1 time

chPoolAlloc fails system state check

Postby elasticdoor » Sun Nov 28, 2021 9:27 pm

Hello,

I am building an application in which I need to allocate and free objects, so I thought I'd do this with a memory pool. The problem is that if I call chPoolAlloc when the runtime system state checks are active, the system halts when I try to instantiate a new object from the pool. If the system state checks are disabled, the program runs normally.

Here is some of my code

Code: Select all

typedef struct cvg_block cvg_block_t;

struct cvg_block {
  cvg_block_t *next;
  uint32_t channel;
  uint16_t cv;
  uint8_t gate;
  uint8_t listeners;
  uint8_t read_count;
};

memory_pool_t cvg_block_mempool;

static THD_WORKING_AREA(testwa, 128);

THD_WORKING_AREA(waChainRoutine, 128);
THD_FUNCTION(ChainRoutine, arg) {
  cvg_block_t *b = (cvg_block_t *)chPoolAlloc(&cvg_block_mempool);

  while(true) {
  }
}

void chSetup() {
  chPoolObjectInit(&cvg_block_mempool, sizeof(cvg_block_t), chCoreAllocAligned);
  chThdCreateStatic(testwa, sizeof(testwa), NORMALPRIO, ChainRoutine, NULL);
}

void setup() {
  chBegin(chSetup);
  /* chBegin should never return */
  while(true) {}
}


This is of course a simplification of the whole code, but I did my best to isolate what I think is the problem.

I am using the following library: https://github.com/greiman/ChRt which is an Arduino port of chibiOS. This is because the platform I'm using is the Teensy4.1. Moreover, because of hardware limitations of the Teensy, I am unable to connect a debugger and look at the panic message.

Any help is appreciated and thank you in advance!

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: chPoolAlloc fails system state check

Postby Giovanni » Sun Nov 28, 2021 9:35 pm

Hi,

I don't see anything obviously wrong in that code (which is a customization, I don't know all the rework done there).

Without a stack trace is not possible to tell which check is failing, you really need a debugger. Note that the check failures could not be related to pools, it could be triggered by something else.

Giovanni


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 14 guests