Commit graph

29 commits

Author SHA1 Message Date
Nisha Gopalakrishnan
6608f84158 BUG#22594514: HANDLE_FATAL_SIGNAL (SIG=11) IN
UNIQUE::~UNIQUE | SQL/UNIQUES.CC:355

Analysis
========

Enabling the sort_buffer_size with a large value
can cause operations utilizing the sort buffer
like DELETE as mentioned in the bug report to
fail. 5.5 and 5.6 versions reports OOM error
while in 5.7+, the server crashes.

While initializing the mem_root for the sort buffer
tree, the block size for the mem_root is determined
from the 'sort_buffer_size' value. This unsigned
long value is typecasted to unsigned int, hence
it becomes zero. Further block_size computation
while initializing the mem_root results in a very
large block_size value. Hence while trying to
allocate a block during the DELETE operation,
an OOM error is reported. In case of 5.7+, the PFS
instrumentation for memory allocation, overshoots
the unsigned value and allocates a block of just
one byte. While trying to free the block of the
mem_root, the original block_size is used. This
triggers the crash since the server tries to free
unallocated memory.

Fix:
====
In order to restrict usage of such unreasonable
sort_buffer_size, the typecast of block size
to 'unsigned int' is removed and hence reports
OOM error across all versions for sizes
exceeding unsigned int range.
2016-03-17 08:49:37 +05:30
Kent Boortz
9da00ebec9 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Mats Kindahl
e409d6f69c WL#5030: Split and remove mysql_priv.h
This patch:

- Moves all definitions from the mysql_priv.h file into
  header files for the component where the variable is
  defined
- Creates header files if the component lacks one
- Eliminates all include directives from mysql_priv.h
- Eliminates all circular include cycles
- Rename time.cc to sql_time.cc
- Rename mysql_priv.h to sql_priv.h
2010-03-31 16:05:33 +02:00
monty@mysql.com/narttu.mysql.fi
088e2395f1 WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:

- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t

Removed declaration of byte, gptr, my_string, my_size_t and size_s. 

Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
  instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
  as this requires fewer casts in the code and is more in line with how the
  standard functions work.
- Added extra length argument to dirname_part() to return the length of the
  created string.
- Changed (at least) following functions to take uchar* as argument:
  - db_dump()
  - my_net_write()
  - net_write_command()
  - net_store_data()
  - DBUG_DUMP()
  - decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
  argument to my_uncompress() from a pointer to a value as we only return
  one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
  the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
  casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.

Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
  needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
  explicitely as this conflict was often hided by casting the function to
  hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
  get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
  size_t. This was needed to properly detect errors (which are
  returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
  (portability fix)
- Removed windows specific code to restore cursor position as this
  causes slowdown on windows and we should not mix read() and pread()
  calls anyway as this is not thread safe. Updated function comment to
  reflect this. Changed function that depended on original behavior of
  my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
  m_size is the number of elements in the array, not a string/memory
  length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
  Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
  - Replaced some calls to alloc_root + memcpy to use
    strmake_root()/strdup_root().
  - Changed some calls from memdup() to strmake() (Safety fix)
  - Simpler loops in client-simple.c
2007-05-10 12:59:39 +03:00
kent@kent-amd64.(none)
be15e3bc15 Merge mysql.com:/home/kent/bk/main/mysql-5.0
into  mysql.com:/home/kent/bk/main/mysql-5.1
2006-12-23 20:20:40 +01:00
kent@mysql.com/kent-amd64.(none)
226a5c833f Many files:
Changed header to GPL version 2 only
2006-12-23 20:17:15 +01:00
monty@narttu.mysql.fi
430d215c58 Merge mysql.com:/home/my/mysql-5.0
into  mysql.com:/home/my/mysql-5.1
2006-11-30 22:38:12 +02:00
monty@mysql.com/narttu.mysql.fi
3d40956039 Fixed portability issue in my_thr_init.c (was added in my last push)
Fixed compiler warnings (detected by VC++):
- Removed not used variables
- Added casts
- Fixed wrong assignments to bool
- Fixed wrong calls with bool arguments
- Added missing argument to store(longlong), which caused wrong store method to be called.
2006-11-30 18:25:05 +02:00
reggie@big_geek.
e815c4c974 Merge rburnett@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into  big_geek.:C:/Work/mysql/mysql-5.1
2006-05-08 15:15:05 -05:00
reggie@big_geek.
11d66e8068 removing MSDOS defines and code 2006-05-08 14:50:13 -05:00
svoj@april.(none)
06ce215f10 BUG#18160 - Memory-/HEAP Table endless growing indexes
Updating data in HEAP table with BTREE index results in wrong index_length
counter value, which keeps growing after each update.

When inserting new record into tree counter is incremented by:
sizeof(TREE_ELEMENT) + key_size + tree->size_of_element
But when deleting element from tree it doesn't decrement counter by key_size:
sizeof(TREE_ELEMENT) + tree->size_of_element

This fix makes accurate allocated memory counter for tree. That is
decrease counter by key_size when deleting tree element.
2006-04-19 15:13:50 +05:00
monty@mysql.com
f34a642d6e after merge fixes 2004-03-18 00:09:13 +02:00
monty@mysql.com
f9ad650490 merge with 4.0 2004-03-17 10:36:12 +02:00
monty@mysql.com
dcf5ba1c95 Increase max size of number of elements in key. This fixed a bug when using count(DISTINCT) with lot of distinct values and big 'max_heap_table_size' 2004-03-16 13:51:35 +02:00
monty@mashka.mysql.fi
dac6498f9b Merge with 4.0 2002-11-21 15:56:48 +02:00
monty@mashka.mysql.fi
e65ddf3fc3 Try to optimize the cache buffer size needed for bulk_insert
Fix for shutdown on Mac OS X
2002-11-20 22:56:57 +02:00
ram@mysql.r18.ru
206a59c8c3 fix for HEAP rb-tree indexes and BIG_TABLES problem (serg: thanks for discovery) 2002-11-11 13:34:47 +04:00
monty@hundin.mysql.fi
ab1a273198 Merge work:/my/mysql-4.1 into hundin.mysql.fi:/my/mysql-4.1 2002-06-04 11:39:33 +03:00
monty@hundin.mysql.fi
920a409ce9 Update results for new SHOW FULL COLUMNS
Portability fixes
2002-06-04 11:32:33 +03:00
ram@gw.udmsearch.izhnet.ru
479b3b3f03 Removed unnecessary key search in the hp_rb_write_key() function 2002-05-28 20:46:35 +05:00
ram@gw.udmsearch.izhnet.ru
3b43cb2960 BTREE heap key structure is now the same as MyISAM
_mi_compare_text -> mi_compate_text
Changes according Monty's suggestions
2002-05-21 21:54:08 +05:00
bar@gw.udmsearch.izhnet.ru
eab2893dac RB-Tree indexes support in HEAP tables
Renamed _hp_func  ->  hp_func
mi_key_cmp moved to /mysys/my_handler.c
New tests for HEAP tables
2002-04-25 13:36:55 +05:00
monty@hundin.mysql.fi
b658662ae4 Update copyright
Fixed memory leak on shutdown (Affects the embedded version & MyODBC)
2001-12-06 14:10:51 +02:00
serg@serg.mysql.com
15b6738474 memory-limited tree
bulk inserts optimization: caching keys in binary tree
2001-07-02 21:18:57 +02:00
sasha@mysql.sashanet.com
ef27ec42c2 option to free_root() to not my_free() the blocks
fixed bug/updated count_distinct2 test
changed reset in count distinct to avoid calls to my_free()
2001-05-12 19:50:51 -06:00
sasha@mysql.sashanet.com
c706bf40f3 use tree for count(distinct) when possible 2001-05-11 15:07:34 -06:00
sasha@mysql.sashanet.com
a12117f036 change tree to use qsort_cmp2 - compare function with 3 instead of 2 arguments 2001-05-10 18:14:15 -06:00
monty@donna.mysql.com
4726593862 Fixes for FULLTEXT and TIME type 2000-09-13 01:08:34 +03:00
bk@work.mysql.com
f4c589ff6c Import changeset 2000-07-31 21:29:14 +02:00