Re:Legitimate Use of Variable Length Arrays
by chollida1 on Monday October 28, 2019 @10:42AM
(#21377417)
I ran into a great alloca bug back in the early days, think 2001 of OS X.
Used alloca to allocate a string on the stack. Depending on the size of the string the colours on the dialog would either look normal or have a rainbow like colour.
Turns out that alloca allocated the data on a non aligned memory address on occasion this caused the quartz compositor, which depended on aligned memory, to draw text with goofy colours.
Moral of the story, I don't use alloca anymore and if I do, I ensure that its aligned properly.
Used alloca to allocate a string on the stack. Depending on the size of the string the colours on the dialog would either look normal or have a rainbow like colour.
Turns out that alloca allocated the data on a non aligned memory address on occasion this caused the quartz compositor, which depended on aligned memory, to draw text with goofy colours.
Moral of the story, I don't use alloca anymore and if I do, I ensure that its aligned properly.