Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Stack overflow in render_outline due to 256KB stack allocation #20

Open
Querijn opened this issue Nov 27, 2022 · 4 comments
Open

Stack overflow in render_outline due to 256KB stack allocation #20

Querijn opened this issue Nov 27, 2022 · 4 comments

Comments

@Querijn
Copy link

Querijn commented Nov 27, 2022

Hey there,

I've encountered a stack overflow crash in render_outline due to the fact that in my setup I cannot allocate 256KB onto the stack.
STACK_ALLOC requires at least 256KB of memory (sizeof(Cell) * 128 * 128) which is not available.

On my setup, I've lowered this number to 32 * 32 which fits fine.

@coelckers
Copy link

I just ran into this as well. Allocating such a large buffer is a major stability concern - Windows executables normally have only one MB of stack available and this has an extremely high chance of causing a stack overflow.

@Querijn
Copy link
Author

Querijn commented Jan 6, 2024

This used to be a problem for me for mods: I can't control how the application uses its stack amount when I am not working in that application. At one point I modified the allocator to just be a regular one, and since no response came from this ticket, I assumed the project wasn't alive, and didn't bother reporting my other issues.

@tomolt
Copy link
Owner

tomolt commented Jan 6, 2024

Alright, thank you, I didn't realize how troublesome this issue is at the time.
I'll lower the stack allocation limit going forward.

and since no response came from this ticket, I assumed the project wasn't alive, and didn't bother reporting my other issues.

Understandable. I still try to maintain and develop libschrift, but I struggle to allocate much time to it these days.

@godmar
Copy link

godmar commented Sep 10, 2024

A comment on the STACK_ALLOC macro. It will always allocate stack space of thresh, even if the needed amount is larger and the actual storage comes from the heap via calloc. A better option may be to use alloca() if it's ok to rely on its presence.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants