0
\$\begingroup\$

During migrating my project to RTOSv2 and RTXv5, I recognize that after a few minutes my program hangs and the messages appear at the RTX RTOS window:

Expression: 'QML[j + QCB[i].ml_idx].addr'
E303: Access out of bounds - <readlist 'QML[44]'> - actual index:=45

I find the source of the hard fault is the "memcpy" function.

CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_msgqueue.c

/// Put a Message into a Queue or timeout if Queue is full.
osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) {
  EvrRtxMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout);
  if (IS_IRQ_MODE() || IS_IRQ_MASKED()) {
    return isrRtxMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout);
  } else {
    return  __svcMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout);
  }
}
...
/// Put a Message into a Queue or timeout if Queue is full.
/// \note API identical to osMessageQueuePut
__STATIC_INLINE
osStatus_t isrRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) {
  os_message_queue_t *mq = (os_message_queue_t *)mq_id;
  os_message_t       *msg;
  const void        **ptr;
  ...
  // Try to allocate memory
  msg = osRtxMemoryPoolAlloc(&mq->mp_info);
  if (msg != NULL) {
    // Copy Message
    memcpy((uint8_t *)msg + sizeof(os_message_t), msg_ptr, mq->msg_size);
    ...
  return osOK;
}

Does anyone have any ideas for this problem? Thanks,...

Bacheh Karaji

\$\endgroup\$
  • \$\begingroup\$ "I find the source of the hard fault is the "memcpy" function." - I strongly doubt that. \$\endgroup\$ – JimmyB Jun 20 '17 at 13:21
0
\$\begingroup\$

I select the Source variant of the software component CMSIS:RTOS2 (API):Keil RTX5, from the Manage Run-Time Environment dialog. Everything Is Fine!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.