Closed cptroot closed 7 years ago
Hmmmmm. I think I misdiagnosed an issue I'm having. I'm still getting the issue even after I combined my two lazy_static macros. Sorry for the bad issue report.
For people in the future who are wondering what my issue was, it seems like I was blowing my stack (I was working on an OS kernel with very small stacks), due to the fact that the lazy_static puts the local variables on the stack (twice in debug mode). Since the variables I were modifying were the size of my entire stack, and because they get put on the stack no matter whether the closure has already run, I ended up writing a custom version of spin::Once to fix my problem with mutable references. This should be fixed in a better way once placement in becomes a thing on nightly.
I'm not sure if this occurs only on the spin_no_std setting, but if you use the lazy static macro twice in one file like:
Will cause the hidden global variable that keeps track of initialization to become corrupted.