mariadb/unittest/mysys
Marc Alff 4075c52b69 Bug#12552516 LF_HASH REQUIRES MY_THREAD_INIT()
Before this fix, a thread instrumented for the performance schema,
that would perform file io operations, could crash inside the LF_HASH
implementation, in cases when my_thread_init is not called.

The crash itself has not been reported in 5.5 but similar crashes have
been found in 5.6-based development branches, using LF_HASH for
more instrumentation.

The possibility of a crash in 5.5 is confirmed by code analysis.

The problem is that, when my_thread_init() is not called,
which can happen for threads in storage engines or thirs party code,
my_thread_var is NULL.

Using my_thread_var->stacks_ends_here in mysys/lf_alloc-pin.c is unsafe.

Given that my_thread_var is used:
- only for stacks_ends_here
- only on platform with HAVE_ALLOCA
- only when there is enough room on the stack
and given that the LF_HASH implementation has a fallback
algorythm implemented already when using alloca is not possible,
using my_thread_var->stacks_ends_here is in fact not a strict requirement,
and can be relaxed.

The fix is to:
- test explicitly if my_thread_var is NULL, to account for cases
  when my_thread_init() is not used by the calling thread.
- not use alloca in this case, and rely on the fall back code already in place.
  so that the LF_HASH can be supported even without my_thread_init().

The implementation of mysys/lf_alloc-pin.c has been fixed to support this new usage.
The units tests in unittest/mysys/lf-t.c have been adjusted accordingly.
2011-05-13 18:04:49 +02:00
..
base64-t.c Bug #43414 Parenthesis (and other) warnings compiling MySQL 2009-09-23 15:21:29 +02:00
bitmap-t.c Bug #11752069 (former bug 43152) 2011-02-23 14:50:59 +01:00
CMakeLists.txt merged mysql-5.5 into WL1054-5.5 2010-08-16 18:16:07 +03:00
lf-t.c Bug#12552516 LF_HASH REQUIRES MY_THREAD_INIT() 2011-05-13 18:04:49 +02:00
my_atomic-t.c Bug#22320: my_atomic-t unit test fails 2010-07-23 09:37:10 -03:00
my_malloc-t.c Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled 2010-07-08 18:20:08 -03:00
my_rdtsc-t.c WL#2373 Use cycle counter for timing 2009-11-24 16:36:31 -07:00
my_vsnprintf-t.c Fix non-portable test of %p in unit test my_vsnprintf 2011-03-02 10:16:34 +01:00
thr_template.c WL#2595 kernel-independent atomic operations 2009-11-17 17:11:32 -07:00