Mark Wielaard <[email protected]> writes:

> When a CU has a really large number of lines dwarf_getsrclines could blow
> up the stack because it uses alloca for temporary storage. Use malloc and
> free if the number of lines gets too big.

We tend to use stack allocation a fair deal in elfutils (61 alloca's
vs. 112 [cm]alloc's; not counting VLA's, as they are hard to grep for).
I'm afraid more of those places might blow up in face of malformed, or
simply huge data.

In glibc, there are macros for handling malloc/alloca splits (alloca if
small, malloc otherwise).  In this case, we don't know the line count in
advance, and would have to use LINEENDP-LINEP as a hint.  But maybe it
would be worth it to port those over, as other places might benefit from
this more directly.  I'll look into it.  For now, your patch makes
sense, except:

> +     if (unlikely (add_new_line (ll, end_seq)))                      \
>         goto invalid_data;                                            \

Wouldn't this leak the malloc'd blocks?

Thanks,
PM
_______________________________________________
elfutils-devel mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/elfutils-devel

Reply via email to