-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
K_KERNEL_STACK_MEMBER causes linker error when used with picolibc and dynamic memory allocation in C++ #57899
Comments
This is somehow pulling in the 'memalign' function, which is not part of the common C library api. This causes the linker to pull in the picolibc internal malloc implementation which no longer works. What is using |
ah, I wonder if the compiler is using memalign internally? I'll provide a PR that you can review to see if it fixes the problem. |
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign appears to be used internally by the G++, so we need to provide an implementation of this when using C++, even though it's not part of the Zephyr C library API. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign appears to be used internally by the G++, so we need to provide an implementation of this when using that compiler, even though it's not part of the Zephyr C library API. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
@keith-packard - any thoughts here? |
This is closed by #58012 which needs another review -- the underlying issue is a bug in gcc which uses |
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: #57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Memalign is another name for the posix aligned_alloc function, although it has weaker restrictions on the relationship between the alignment and size. memalign() is used internally by the libstdc++ when built for 'newlib' targets (which includes picolibc) instead of aligned_alloc() due to a bug in gcc, so we need to provide an implementation of this when using that library, even though it's not part of the Zephyr C library API. When a fix for the libstdc++ is merged upstream and can be consider a reasonable dependency for Zephyr, this work-around can be removed. Closes: zephyrproject-rtos#57899 Signed-off-by: Keith Packard <[email protected]>
Describe the bug
When you try to allocate structure/class with
K_KERNEL_STACK_MEMBER
as its member and you have enabledHW_STACK_PROTECTION
and picolibc then there is observed a linker error as below.When newlib is used or
HW_STACK_PROTECTION
is disabled then the same application is built without problems.To Reproduce
Code:
Configuration:
Build command (the same for nrf52840_mdk, npcx7m6fb_evb or any other platform with HW stack protection capability):
west build -p always -b nucleo_wb55rg .
Expected behavior
Application should build without errors.
Impact
showstopper
Logs and console output
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: