Stack Alignemt failure

Report here problems in any of ChibiOS components. This forum is NOT for support.
jawe
Posts: 3
Joined: Wed Oct 30, 2024 1:11 pm
Been thanked: 1 time

Stack Alignemt failure

Postby jawe » Wed Nov 06, 2024 1:53 pm

I happened to pull the very recent version of chibios into a project and ran into a stackalignment issue.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@16732 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
Platfrom: armv7-M STM32H745

This included the recent changes about renaming stkalign_t in stkline_t

Code: Select all

Renamed stkalign_t in stkline_t, the type is no more related to stack alignment enforcement. Reviewed TCB alignment in working areas for legacy thread creation functions.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@16720 27425a3e-05d8-49a3-a47f-9c15f0e5edd8


A stack created by

Code: Select all

chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(thdWaSize), "name", PRIO, thread, (void *)arg);

does fail the test

Code: Select all

MEM_IS_ALIGNED(tdp->wend, PORT_STACK_ALIGN)

in chThdCreateSuspendedI now.

With the recent changes I understand that the stkline_t is no longer meant to be used for alignment. And the macros like PORT_STACK_ALIGN should be used for the job.
As I understand my platform is using 8 byte for stkline_t, and the alignments macros are all now setup for 32 bytes instead of sizeof(stkline_t).

However the current macros for THD_WORKING_AREA still use stkline_t for alignment as far as I can see.
Since this is a very recent change this might just be an in development feature and not done yet. But I also saw a mention of legacy thread creation functions. Am I just using an old API here and that's why it fails alignment? Or is this really just too new to be used at the moment?

Currently statically allocated threads still start even if the working area is setup with the macro THD_WORKING_AREA(_SIZE), this seems to be because chThdCreateStatic does not actually check for

Code: Select all

MEM_IS_ALIGNED(tdp->wend, PORT_STACK_ALIGN)

like chThdCreateSuspendedI does.

User avatar
Giovanni
Site Admin
Posts: 14535
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1097 times
Been thanked: 934 times
Contact:

Re: Stack Alignemt failure

Postby Giovanni » Wed Nov 06, 2024 3:45 pm

Hi,

Thanks for reporting, will fix on trunk as soon as possible.

Your understanding is correct.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14535
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1097 times
Been thanked: 934 times
Contact:

Re: Stack Alignemt failure

Postby Giovanni » Thu Nov 07, 2024 7:23 am

Hi,

Give it a try again, committed fixes. You may need to wait that the github repository synchronizes with the official subversion one, it is a daily thing if I remember well.

Note that you are looking at "trunk" code which is in active development, if you are not interested in the very latest stuff you may consider using the latest stable branch: 21.x. Trunk is usually stable enough for development but regressions can happen.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 14 guests