Page MenuHomeFreeBSD

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

Authored by daniel_octaforge.org on Jun 3 2023, 10:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Feb 25, 12:53 AM
Unknown Object (File)
Tue, Feb 4, 12:33 AM
Unknown Object (File)
Jan 25 2025, 8:14 AM
Unknown Object (File)
Jan 18 2025, 5:45 AM
Unknown Object (File)
Jan 10 2025, 8:28 AM
Unknown Object (File)
Jan 10 2025, 2:24 AM
Unknown Object (File)
Jan 5 2025, 4:05 AM
Unknown Object (File)
Dec 18 2024, 11:33 AM
Subscribers
None

Details

Summary

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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

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