Commit graph

52 commits

Author SHA1 Message Date
Tor Didriksen
98e8c41ef8 Use vsnprintf() rather than my_vsnprintf() in DbugVfprintf,
since support for "%g" and "%f" has not been backported yet.
2009-11-27 15:40:33 +01:00
Sergei Golubchik
d3bf417db2 robust protection against missing DBUG_RETURN
(instead of a C++ only thingy that was lost in a merge)
2009-10-31 08:23:47 +01:00
Sergei Golubchik
6eaf0b5acb backport of dbug extensions from 6.0:
function/ syntax
  glob(7) wildcards
  unit tests
2009-10-30 19:13:58 +01:00
Alfranio Correia
5280dc82c1 WL#4828 and BUG#45747
NOTE: Backporting the patch to next-mr.

WL#4828 Augment DBUG_ENTER/DBUG_EXIT to crash MySQL in different functions
-------

The assessment of the replication code in the presence of faults is extremely
import to increase reliability. In particular, one needs to know if servers
will either correctly recovery or print out appropriate error messages thus
avoiding unexpected problems in a production environment.

In order to accomplish this, the current patch refactories the debug macros
already provided in the source code and introduces three new macros that
allows to inject faults, specifically crashes, while entering or exiting a
function or method. For instance, to crash a server while returning from
the init_slave function (see module sql/slave.cc), one needs to do what
follows:

1 - Modify the source replacing DBUG_RETURN by DBUG_CRASH_RETURN;

  DBUG_CRASH_RETURN(0);

2 - Use the debug variable to activate dbug instructions:

  SET SESSION debug="+d,init_slave_crash_return";

The new macros are briefly described below:

DBUG_CRASH_ENTER (function) is equivalent to DBUG_ENTER which registers the
beginning of a function but in addition to it allows for crashing the server
while entering the function if the appropriate dbug instruction is activate.
In this case, the dbug instruction should be "+d,function_crash_enter".

DBUG_CRASH_RETURN (value) is equivalent to DBUG_RETURN which notifies the
end of a function but in addition to it allows for crashing the server
while returning from the function if the appropriate dbug instruction is
activate. In this case, the dbug instruction should be
"+d,function_crash_return". Note that "function" should be the same string
used by either the DBUG_ENTER or DBUG_CRASH_ENTER.

DBUG_CRASH_VOID_RETURN (value) is equivalent to DBUG_VOID_RETURN which
notifies the end of a function but in addition to it allows for crashing
the server while returning from the function if the appropriate dbug
instruction is activate. In this case, the dbug instruction should be
"+d,function_crash_return". Note that "function" should be the same string
used by either the DBUG_ENTER or DBUG_CRASH_ENTER.

To inject other faults, for instance, wrong return values, one should rely
on the macros already available. The current patch also removes a set of
macros that were either not being used or were redundant as other macros
could be used to provide the same feature. In the future, we also consider
dynamic instrumentation of the code.


BUG#45747 DBUG_CRASH_* is not setting the strict option
---------
      
When combining DBUG_CRASH_* with "--debug=d:t:i:A,file" the server crashes
due to a call to the abort function in the DBUG_CRASH_* macro althought the
appropriate keyword has not been set.
2009-09-29 14:55:36 +01:00
Vladislav Vaintroub
4dfbf2ec93 Bug#38522: 5 seconds delay when closing application using embedded server
The problem here is that embedded server starts handle_thread manager 
thread  on mysql_library_init() does not stop it on mysql_library_end().
At shutdown, my_thread_global_end() waits for thread count to become 0,
but since we did not stop the thread it will give up after 5 seconds.
             
Solution is to move shutdown for handle_manager thread from kill_server()
(mysqld specific) to clean_up() that is used by both embedded and mysqld.
            
This patch also contains some refactorings - to avoid duplicate code,
start_handle_manager() and stop_handle_manager() functions are introduced.
Unused variables are eliminated. handle_manager does not rely on global
variable abort_loop anymore to stop (abort_loop is not set for embedded).
            
Note: Specifically on Windows and when using DBUG version of libmysqld, 
the complete solution requires removing obsolete code my_thread_init() 
from my_thread_var(). This has a side effect that a DBUG statement 
after my_thread_end() can cause thread counter to be incremented, and 
embedded will hang for some seconds. Or worse, my_thread_init() will 
crash if critical sections have been deleted by the global cleanup 
routine that runs in a different thread. 

This patch also fixes and revert prior changes for Bug#38293 
"Libmysqld crash in mysql_library_init if language file missing".

Root cause of the crash observed in Bug#38293  was bug in my_thread_init() 
described above
2008-12-04 19:41:53 +01:00
Alexey Botchkov
70e8a4fd54 Bug#38293 Libmysqld crash in mysql_library_init if language file missing
That's a Win-specific error.
    When we create libmysqld.dll we have many libraries like mysys, dbug,
    strings, etc linked into that dll, so the application built upon
    this library shouldn't link these libraries to itself, rather use
    those inside the dll.

    Fixed by redirecting calls into the libmysqld.dll

per-file comments:
  dbug/dbug.c
Bug#38293 Libmysqld crash in mysql_library_init if language file missing
    fake _db_something definitions added

  include/my_dbug.h
Bug#38293 Libmysqld crash in mysql_library_init if language file missing
  fake _db_something declarations added

  libmysqld/examples/CMakeLists.txt
Bug#38293 Libmysqld crash in mysql_library_init if language file missing
    superfluous libraries removed from linking

  libmysqld/libmysqld.def
Bug#38293 Libmysqld crash in mysql_library_init if language file missing
    set of mysys functions added to the export section
2008-11-19 13:57:23 +04:00
msvensson@pilot.mysql.com
8d35b57b37 Merge pilot.mysql.com:/data/msvensson/mysql/my50-bt-36463
into  pilot.mysql.com:/data/msvensson/mysql/mysql-5.1-bugteam
2008-05-02 19:42:34 +02:00
msvensson@pilot.mysql.com
4cede4a3bf Bug#35986 valgrind warning in DbugParse for empty string in SET GLOBAL DEBUG=""
- Code in DbugParse was reading from beyond end of the control string
2008-05-02 12:49:31 +02:00
iggy@amd64.(none)
79e434bc67 Bug#26243 mysql command line crash after control-c
- Backported the 5.1 DBUG to 5.0.
- Avoid memory cleanup race on Windows client for CTRL-C
2008-03-28 14:02:27 -04:00
davi@mysql.com/endora.local
cdd5eae9b6 Bug#34424 query_cache_debug.test leads to valgrind warnings
Bug#34678 @@debug variable's incremental mode

The problem is that the per-thread debugging settings stack wasn't
being deallocated before the thread termination, leaking the stack
memory. The chosen solution is to push a new state if the current
is set to the initial settings and pop it (free) once the thread
finishes.
2008-02-26 12:03:59 -03:00
gkodinov/kgeorge@magare.gmz
ba03c12b24 Bug #27099: system_mysql fail in pushbuild windows
On Windows the debug log was doing freopen () instead of
fflush() and that was slowing the logging down that much 
that some tests timed out.
Fixed by replacing the freopen() with an syncing-to-disk
flag to fopen() and fflush().
Also increased the timeout of the tests running with --debug
on windows : seems to slow down as much as valgrind on linux.
2007-10-15 19:56:24 +03:00
monty@mysql.com/nosik.monty.fi
4f33d95fa3 Set --debug-check if one uses DBUG_PUSH in all clients
Fixed bug in query cache that made it impossible to run mysqld with --debug
Fixed memory leaks in mysqldump and mysqltest
Memory leaks associated with wrong usage of mysqltest is not fixed. To find these, run
mysql-test-run --debug mysqltest
2007-08-02 07:49:29 +03: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
serg@janus.mylan
e9fb4a686f dbug/dbug.c: unused variable removed
include/config-win.h: SIZEOF_INT
include/my_global.h: win64 fix
support-files/Makefile.am: automake magic
2007-03-17 11:19:21 +01:00
serg@janus.mylan
689eed7406 Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into  janus.mylan:/usr/home/serg/Abk/mysql-5.1
2007-02-21 11:36:23 +01:00
serg@janus.mylan
24186aa176 dbug: don't consider double colom (::) a separator -
it can be part of a function name (Item::reset)
2007-01-28 21:11:42 +01:00
df@kahlann.erinye.com
eadd2c4eef Build fix for sunfire100b. This can go when BUG#14420 is fixed. 2007-01-27 22:07:52 +01:00
monty@mysql.com/narttu.mysql.fi
23263db66e Added back sql-bench directory, so that one can more easily run benchmarks on a server and add new benchmarks for new optimizations
Fixed memory leak in _db_set() (Bug#24497 Valgrind warning: get_one_option)
Don't call net_clear() on COM_QUIT. This avoids a warning from net_clear() after shutdown: "skipped ## bytes from file"
BUG#21428: skipped 9 bytes from file: socket (3)" on "mysqladmin shutdown"
2006-11-29 22:51:09 +02:00
cmiller@zippy.cornsilk.net
461afda9bb Fix build problem for when not compiled with debugging. 2006-09-06 17:10:58 -04:00
msvensson@neptunus.(none)
d58af76d68 Merge neptunus.(none):/home/msvensson/mysql/bug21749/my50-bug21749
into  neptunus.(none):/home/msvensson/mysql/bug21749/my51-bug21749
2006-08-24 12:19:41 +02:00
msvensson@neptunus.(none)
b25b49a05a Cset exclude: msvensson@neptunus.(none)|ChangeSet|20060612110740|13873 2006-08-24 11:39:52 +02:00
kostja@bodhi.local
d4a7b82be9 Windows build fix: declare _db_set_ before it's used. 2006-08-14 16:15:08 +04:00
kostja@bodhi.local
04c97488f9 Merge bodhi.local:/opt/local/work/tmp_merge
into  bodhi.local:/opt/local/work/mysql-5.1-runtime-merge
2006-08-12 21:06:51 +04:00
serg@serg.mylan
48c453a40b atomic ops:
my_atomic_XX_t -> intXX, no implicit locking anymore
    simplified framework, support for requested cleanups
2006-06-17 16:20:39 +02:00
msvensson@neptunus.(none)
4ca95f911a Bug#19517 No simple way to detect wether server was compiled with libdbug
- Define DBUG_ON and DBUG_OFF in config.h
2006-06-12 13:07:40 +02:00
knielsen@mysql.com
f82c39ce4b After-merge fixes. 2006-05-17 15:01:48 +02:00
knielsen@mysql.com
a729d7fcdd Merge mysql.com:/usr/local/mysql/mysql-5.0-vgfix
into  mysql.com:/usr/local/mysql/tmp-5.1
2006-05-16 14:34:35 +02:00
knielsen@mysql.com
fc16aff742 Fix two Valgrind memory leak warnings. 2006-05-15 18:07:18 +02:00
brian@zim.(none)
5d1d27c016 Final patch to remove the last of the OS2 support. 2006-04-15 18:17:32 -07:00
konstantin@mysql.com
0ff41a11d2 Fix an const char->char conversion error. 2006-02-23 14:18:17 +03:00
kent@mysql.com
a50023d772 mysqlimport.c:
Handle case where there is no snprintf()
libmysql.vcproj, mysqlclient.vcproj:
  Added __WIN__ symbol, needed when compiling dbug.c
dbug.vcproj:
  Changed __WIN32__ to __WIN__
dbug.c:
  Added Windows specific code to handle TIMESTAMP_ON log line format
make_win_src_distribution.sh:
  Copy plugin directory recursively
dbug.vcproj:
  Define __WIN__ for all targets
2006-02-18 08:46:18 +01:00
serg@serg.mylan
4e68f1ba3a post-merge fixes for dbug 2006-02-15 00:14:37 +01:00
serg@serg.mylan
63cfd11859 dbug changes:
1. dbug state is now local to a thread
2. new macros: DBUG_EXPLAIN, DBUG_EXPLAIN_INITIAL,
   DBUG_SET, DBUG_SET_INITIAL, DBUG_EVALUATE, DBUG_EVALUATE_IF
3. macros are do{}while(0) wrapped
4. incremental modifications to the dbug state (e.g. "+d,info:-t")
5. dbug code cleanup, style fixes
6. _db_on_ and DEBUGGER_ON/OFF removed
7. rest of MySQL code fixed because of 3 (missing ;) and 6
8. dbug manual updated
9. server variable @@debug (global and local) to control dbug from SQL!
a. -#T to print timestamps in the log
2006-02-14 22:36:11 +01:00
monty@mysql.com
3fb088a075 Add 0x before pointers (to help with debugging)
Add support for VARCHAR with 1 or 2 length bytes
Enable VARCHAR packing in MyISAM files (previous patch didn't pack data properly)
Give error if we got problems in temporary tables during a SELECT
Don't use new table generated by ALTER TABLE if index generation fails
Fixed wrong call by range_end() (Could cause an ASSERT in debug mode)
2004-12-18 05:19:21 +02:00
serg@serg.mylan
87840e841c Merge bk-internal:/home/bk/mysql-5.0
into serg.mylan:/usr/home/serg/Abk/mysql-5.0
2004-11-15 19:27:06 +01:00
monty@mysql.com
c7e85ef9b9 More debugging
Print position in normal log for Binlog dump
2004-11-10 18:07:39 +02:00
serg@serg.mylan
353dd4fe35 dbug: DBUG_EXECUTE_IF macro, build user manual automatically, document all features
charset2html moved from mysys to extra
ignore: new files added, garbage removed
2004-11-04 22:29:00 +01:00
dlenev@brandersnatch.localdomain
03b705ff44 Made my_snprintf() behavior snprintf() compatible when printing %x arguments (it should
produce hex digits in lower case). (fixed version)

Replaced _dig_vec array with two _dig_vec_upper/_dig_vec_lower arrays.
Added extra argument to int2str function which controls case of digits you get.
Replaced lot of invocations of int2str for decimal radix with more optimized int10_to_str()
function.
Removed unused my_itoa/my_ltoa functions.
2004-05-27 17:54:40 +04:00
ram@gw.mysql.r18.ru
f231d9826b just tried to find all 'skipp' and replace it with 'skip'. 2004-02-02 20:25:39 +04:00
monty@mysql.com
e0cc6799ec Merge with 4.0.17 2003-12-17 17:35:34 +02:00
monty@mysql.com
6a95123971 Added checking of return value from my_once_alloc() in charset
Added checking of return value from malloc() in reg_init()
2003-12-10 00:00:20 +02:00
monty@narttu.mysql.fi
23145cfed7 Added SQLSTATE to client/server protocol
bmove_allign -> bmove_align
Added OLAP function ROLLUP
Split mysql_fix_privilege_tables to a script and a .sql data file
Added new (MEMROOT*) functions to avoid calling current_thd() when creating some common objects.
Added table_alias_charset, for easier --lower-case-table-name handling
Better SQL_MODE handling (Setting complex options also sets sub options)
New (faster) assembler string functions for x86
2003-06-04 18:28:51 +03:00
monty@mashka.mysql.fi
8edc752573 Simple fixes (nothing notable) 2003-03-12 01:40:06 +02:00
monty@mashka.mysql.fi
2aecdd1a91 Big code cleanup/review before 4.0.2 release.
(All commit emails since 4.0.1 checked)
This had to be done now, before the 4.1 tree changes to much, to make it easy to propagate bug fixes to the 4.1 tree.
2002-06-11 11:20:31 +03:00
sasha@mysql.sashanet.com
be388422eb replication updates. This changeset seems to be working fine on test systems.
If no problems are discovered in the next week, this will make the replication
code ready for 4.0.2 release.
2002-03-30 12:36:05 -07:00
sasha@mysql.sashanet.com
f28f8d086d coverted my_thread_init() /end to use my_malloc()/my_free() to help track
down replication corruption
2002-03-26 22:19:23 -07:00
monty@hundin.mysql.fi
4609e627a5 Increase max package length to 512M for mysql and mysqldump.
Faster 'read_first_row' (Fixes slow 'preparing' state)
Read constant tables earlier, which provides better optimzations when using tables with <=1 row.
This also fixes a complicated bug involving const tables.
2002-01-23 02:52:26 +02:00
monty@hundin.mysql.fi
7cadc6e711 Changed to use my_global.h
Fixed problem with LIKE with latin1_de
Added parsing support of UNSIGNED LONG LONG
2001-09-14 02:54:33 +03:00
monty@hundin.mysql.fi
6000cd213a Portability fixes 2001-08-30 10:51:36 +03:00
monty@hundin.mysql.fi
733f865f54 Fixes for OS2.
Fix bug in isamlog
Add argument types to function declarations.
2001-08-22 01:45:07 +03:00