Page MenuHomeFreeBSD

sh(1): make smark a static variable instead of a local in main()

Authored by on Jun 3 2023, 10:44 PM.
Referenced Files
Unknown Object (File)
Sat, Nov 11, 8:31 PM
Unknown Object (File)
Sat, Nov 11, 3:37 PM
Unknown Object (File)
Nov 7 2023, 7:23 AM
Unknown Object (File)
Nov 6 2023, 4:11 AM
Unknown Object (File)
Oct 10 2023, 2:35 PM
Unknown Object (File)
Oct 8 2023, 7:31 PM
Unknown Object (File)
Oct 6 2023, 6:19 AM
Unknown Object (File)
Oct 5 2023, 3:07 AM



We are modifying it after setjmp and then accessing it after the jump, so it cannot be a local.

Diff Detail

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

I agree with the analysis, but the variables should still be defined inside main (with static) so they cannot be used outside. Some of the other functions in this file have their own smark locals that should not be mixed up with main's.

An alternative fix could be to change setstackmark and popstackmark to return/take the struct stackmark by value and make main's variables volatile. I'm not really sure that's better than just adding the static keyword though.

yes, you are right; i have changed it

This revision is now accepted and ready to land.Jun 4 2023, 8:17 PM