Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Description of defect
Function 'call_every' from EventQueue class should return unique ID that represents the posted event or an ID of 0 if there is not enough memory. If ID is greater than 0, everything is perfect. Sometimes it returns negative value (different) and such event is not working properly, ie event is running well but function 'time_left' returns invalid value -1 and it is not possible to cancel this event (it's running forever).
Target(s) affected by this defect ?
Toolchain(s) (name and version) displaying this defect ?
What version of Mbed-os are you using (tag or sha) ?
mbed-os-5.13.4 and mbed-os-5.10.0
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
How is this defect reproduced ?
Run this code. If is everything perfect, it will prints everytimes 10 numbers per a line to console. Everytimes the event with negative ID occurs, the amount of number increases by 10.
I've looked at this, and I can see potential flaws, but I'm not sure how you're getting a negative ID in your example.
The ID you're given is formed from an 8-bit internal ID shifted up above a buffer offset, which is sized according to the size of the buffer.
For the combined result to be negative, the event queue buffer size would have to be 24-bit (so >= 8MiB), as far as I can see.
I'll post a patch making some changes, and we can see if it helps anything. But my test requires a big buffer...?
@kjbracey-arm Good point, the ID in example above is only 16 bit number and that's the problem. In my real code there was also a 16 bit temporal variable for debug and it overflows... I apologize for the stupid mistake. The EventQueue is working properly until the queue size is >= 8MiB. Thank you for your time.