From mboxrd@z Thu Jan 1 00:00:00 1970 From: stefan_seefeld@mentor.com (Stefan Seefeld) Date: Sun, 9 Feb 2014 11:28:38 -0500 Subject: [lttng-dev] RFC: Fix crash in dlerror() In-Reply-To: <905376946.21151.1391898148330.JavaMail.zimbra@efficios.com> References: <52F55511.2080309@mentor.com> <1380151240.21051.1391875592403.JavaMail.zimbra@efficios.com> <52F66118.5010003@mentor.com> <905376946.21151.1391898148330.JavaMail.zimbra@efficios.com> Message-ID: <52F7ACB6.4060907@mentor.com> On 02/08/2014 05:22 PM, Mathieu Desnoyers wrote: > Interesting approach. I assume here you are referring to the temporary static allocator we use during calloc initialization, not my initializing realloc at the same time ? > Then I wonder if we couldn't simply lookup every symbol > we're interested in whenever any of the overridden function is called and > we notice a NULL pointer, and provide a simplistic "static" allocator for > every function overridden. While I agree that a consistent technique to solve the initialization problem has a lot of appeal, I'm actually hesitant in this particular case: One important limitation of the static allocator is that it requires an upper bound for the buffer. This works fine if we know the circumstance where it is used (I believe dlsym() itself calls calloc() to allocate a global structure that requires 32 bytes). The case I discovered on Friday, however, uses realloc() from within vasprintf(), which needs to grow a buffer to hold an error message, and I don't think the size of that is bounded. Therefore, using a static allocator in that situation seems dangerous. An entirely different argument is that you are suggesting to rewrite an entire library (albeit a small one), when we are trying to get a bugfix into a release even after code freeze. But who am I to tell you that. ;-) Regards, Stefan -- Stefan Seefeld CodeSourcery / Mentor Graphics http://www.mentor.com/embedded-software/