This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libdw. Don't blow up stack in dwarf_getsrclines with lots of lines.

Mark Wielaard <> 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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]