Skip to content

Only allow one thread for unsafe stdlib #1907

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

Merged
merged 4 commits into from
Jun 12, 2016

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Jun 11, 2016

No description provided.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jun 11, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

2 similar comments
@bridadan
Copy link
Contributor

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@bridadan
Copy link
Contributor

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@mbed-bot
Copy link

[Build 463]
FAILURE: Something went wrong when building and testing.

@bridadan
Copy link
Contributor

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@mbed-bot
Copy link

[Build 464]
FAILURE: Something went wrong when building and testing.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jun 12, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

c1728p9 added 4 commits June 12, 2016 18:18
The main stack ends at the start of the heap.  In some configurations
this causes the guard word to be overwritten when memory is allocated.
This causes an OS error in RTX since it appears that the main stack
overflowed.

This patch moves the main stack to the upper 1/4th of the heap which
prevents the guard word from getting overwritten.
The define OS_TCB_SIZE does not match the real stack size.  This
leaves the system with less than OS_TASKCNT TCBs and prevents
a single thread configuration.  This updates OS_TCB_SIZE to the
correct value to fix the problem.
When using a standard library which does not support multi-threading
allow only one thread to be used.  This allows the code to remain
safe.
When the malloc lock and unlock functions are inside a library they
conflict with the standard libraries weak version of these functions.
This is because of the way weak references are handled by the linker.
This patch renames the lock and unlock functions defined inside RTX
so they do not conflict.  A thunk inside retarget.cpp then calls the
RTX functions.  This problem does not occur with retarget.cpp since
it is always build into an object file rather than a library file.
@mbed-bot
Copy link

[Build 467]
FAILURE: Something went wrong when building and testing.

@c1728p9 c1728p9 force-pushed the only_allow_one_thread_for_unsafe_stdlib branch from 0bf8adf to d0b7b3b Compare June 12, 2016 18:05
@c1728p9
Copy link
Contributor Author

c1728p9 commented Jun 12, 2016

@mbed-bot: TEST

HOST_OSES=windows
BUILD_TOOLCHAINS=IAR,ARM
TARGETS=NUCLEO_F411RE,LPC1768,K64F, KL25Z,NUCLEO_L053R8,MAX32600MBED

@@ -50,7 +50,7 @@
#define _declare_box(pool,size,cnt) uint32_t pool[(((size)+3)/4)*(cnt) + 3]
#define _declare_box8(pool,size,cnt) uint64_t pool[(((size)+7)/8)*(cnt) + 2]

#define OS_TCB_SIZE 52
#define OS_TCB_SIZE 60
Copy link
Contributor

@0xc0170 0xc0170 Jun 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this sizeof OS_TCB as I recall? have we changed it , or the 52 was miscalculation on our side?

I dont fully understand the fix (how it fixes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it is the size of OS_TCB. It was defiantly too small on the cortex M. I didn't run the cortex A but I think this one was too small as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I git blame, seems like void *context was aded there, did I miss anything else? that would make it only increased by 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I printed out the size for cortex M and it was 60

Copy link
Contributor

@0xc0170 0xc0170 Jun 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, so for cortex-m it's 60,but cortex a was not changed with context pointer, thus might be different.

cc @TomoYamanaka please have a look at this changeset

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi.

Code of review test is completed.There is no problem.

Regards,
Yamanaka

@mbed-bot
Copy link

[Build 470]
FAILURE: Something went wrong when building and testing.

@sg- sg- merged commit 5acdad9 into ARMmbed:master Jun 12, 2016
@svastm
Copy link
Contributor

svastm commented Jun 29, 2016

Hello @c1728p9.

Something has been decided about the limit between the small and standard build ? Should we change the default_toolchain from uARM to ARM on standard targets too ?

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jun 29, 2016

Hi @svastm, it doesn't hurt to change the default to ARM. The default toolchain field might be removed in the future though since this is duplicate information.

@ohagendorf
Copy link
Contributor

I don't understand the choosen "default_build" options:

e.g. an EFM32PG with 256KB/32KB (flash/ram) gets a "default_build": "standard", a lot of other MCUs several with much more flash/ram (STM32F407VG with 1024kb/192kb, ...) gets a "default_build": "small". A DISCO_F401VC gets a "default_build": "standard" and a NUCLEO_F401RE - same mcu but with twice the flash size - gets only a "default_build": "small". Why?

With this option RTOS is not available (for GCC) maybe also other things did not work.

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

Successfully merging this pull request may close these issues.

8 participants