Skip to content

Accessors set_priority/get_priority crash if called on an unstarted thread #14632

Open
@rotu

Description

@rotu

Description of defect

If a thread object is created but not yet started, priority accessors behave strangely:

  • get_priority() returns osPriorityError, not the priority value passed to the constructor.
  • set_priority() causes a fault condition instead of changing the priority value when the thread is later started.

This is understandable from an implementation perspective but quite surprising from an interface perspective, since these objects have a priority passed to the constructor, so this value exists before starting the thread.

Target(s) affected by this defect ?

NUCLEO_F446ZE

Toolchain(s) (name and version) displaying this defect ?

ARMC6

What version of Mbed-os are you using (tag or sha) ?

376fda5

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Mbed studio 1.4.1

How is this defect reproduced ?

This code:

printf("creating thread with priority %d\n", create_pri);
Thread t{create_pri};
osPriority_t got_pri = t.get_priority();
printf("get_priority() = %d\n", got_pri);
t.set_priority(osPriorityNormal);
printf("this line will never be reached\n");

emits this output:

creating thread with priority 32
get_priority() = -1


++ MbedOS Error Info ++
Error Status: 0x80010132 Code: 306 Module: 1
Error Message: Thread: 0x0, Parameter error
Location: 0x80095F5
Error Value: 0x0
Current Thread: main Id: 0x20001A88 Entry: 0x800680D StackSize: 0x1000 StackMem: 0x200004F8 SP: 0x2001FF44 
For more info, visit: https://mbed.com/s/error?error=0x80010132&tgt=NUCLEO_F446ZE
-- MbedOS Error Info --

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions