tagteam / prodlim

Product limit estimation for survival analysis
7 stars 9 forks source link

ns*ns allocation may be better with Calloc #9

Closed MichaelChirico closed 2 months ago

MichaelChirico commented 2 months ago

https://github.com/tagteam/prodlim/blob/4f8748df44777ce8f18d532e4c35ec4548b031ef/src/prodlim_multistates.c#L72

That attempts to put ns*ns doubles on the stack; I imagine that will make it pretty easy to generate a stack overflow with input using a large number of states.

This was flagged by the -Wvla compiler warning and indeed looks like a place where we may prefer heap allocation.

tagteam commented 2 months ago

thanks. the number of states is usually below 10 in this type of analysis