Re: A quiz: Re: Second patch attempt for PATH_MAX fix in ruby1.9.1- 1.9.3~rc1-3
On Sun, 2011-11-06 at 01:52 +0100, Samuel Thibault wrote:
> Svante Signell, le Fri 14 Oct 2011 17:48:31 +0200, a écrit :
> > /* Avoid consuming stack as this module may be used from signal handler */
> > static char *binary_filename = NULL;
> >
> > It wouldn't work with alloca, maybe with malloc!
> malloc has to be checked with
> upstream. If rb_dump_backtrace_with_lines is to be called from a *Unix*
> signal handler, then it is not safe to call malloc. The only solution
> is then to use a fixed-length array, i.e. the ifndef PATH_MAX define
> PATH_MAX lazy solution.
I contacted upstream and they added the conditional definition of
PATH_MAX to 4096 in commit: r33675. A fixed-length buffer was the only
solution as you pointed out since the code at hand is run when the
program has crashed.
Thanks for your comments on alloca/malloc/realloc anyway.
Reply to: