Skip to content

Small message types for Mail objects cause errors? #4910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SakuGlumoff opened this issue Aug 15, 2017 · 4 comments
Closed

Small message types for Mail objects cause errors? #4910

SakuGlumoff opened this issue Aug 15, 2017 · 4 comments
Assignees

Comments

@SakuGlumoff
Copy link

Description

  • Type: Bug | Question

Target
NUCLEO_F429ZI

I am using a Mail object for one of my threads for inter-thread communications.
The message type struct basically contains two enums (result and command).

typedef enum {
  MESSAGE_ERROR = -1,

  MESSAGE_OK = 0
} MessageResult;

typedef enum {
  COMMAND_ACTION_1,
  COMMAND_ACTION_2,
  COMMAND_ACTION_3
} MessageCommand;

typedef struct {
   MessageResult result;
   MessageCommand command;
} message_t;

I have been testing the functionality in the online compiler where my main() function is very simple as to just show that the program runs without problems:

static Mail<message_t, 10> mailBox;
int main() {
    
    int i = 0;
    while (1) {
        printf("asd %d\r\n", i++);
    }
    
    return 0;
}

However, when I compile the program (mbed online compiler), the program output to the serial port is:

mbed assertation failed: _id, file: /extras/mbed-os.lib/rtos/MemoryPool.h, line 58

Now, when I add some padding to lengthen the message struct like this:

typedef struct {
   MessageResult result;
   MessageCommand command;
   union {
       bool val;
       uint16_t val2;
   } padding;
} message_t;

The program runs correctly with output:

asd 5966
asd 5967
asd 5968
asd 5969
asd 5970
asd 5971
...

Do you have any idea as to what causes this?
I have also tested this with the offline compiler using the GCC_ARM toolchain - same results, although the serial output is:

Memory Pool 0x0 error -10

@SenRamakri
Copy link
Contributor

I'm able to reproduce this issue, looking into this.

@SakuGlumoff
Copy link
Author

Thank you.

@bulislaw
Copy link
Member

Should be fixed internally in #4941

@bulislaw
Copy link
Member

Closing as #4941 was merged. Please reopen if you still have issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants