strict aliasing violations.
Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.
As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.
The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.
client/mysql.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysql_upgrade.c:
Remove now-unnecessary casts.
client/mysqladmin.cc:
Remove now-unnecessary casts.
Break up large strings.
client/mysqlbinlog.cc:
Remove now-unnecessary casts.
client/mysqlcheck.c:
Remove now-unnecessary casts.
client/mysqldump.c:
Remove now-unnecessary casts.
client/mysqlimport.c:
Remove now-unnecessary casts.
client/mysqlshow.c:
Remove now-unnecessary casts.
client/mysqlslap.c:
Remove now-unnecessary casts.
client/mysqltest.cc:
Remove now-unnecessary casts.
extra/comp_err.c:
Remove now-unnecessary casts.
extra/my_print_defaults.c:
Remove now-unnecessary casts.
Break up large strings.
extra/mysql_waitpid.c:
Remove now-unnecessary casts.
extra/perror.c:
Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
Remove now-unnecessary casts.
extra/resolveip.c:
Remove now-unnecessary casts.
include/my_getopt.h:
Use a void pointer type as the opaque type to avoid problems with type
incompatibility -- GCC issues warnings when the type name is not type
compatible with a operand. As a side bonus, a explicit cast won't be
necessary anymore.
include/sslopt-longopts.h:
Remove now-unnecessary casts.
Break up large strings.
mysys/my_getopt.c:
Update opaque type and introduce a type definition for the
argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
Remove now-unnecessary casts.
sql/mysqld.cc:
Remove now-unnecessary casts.
Break up large strings.
Update mysql_getopt_value prototype (the old prototype
was different from the definition anyway).
sql/sql_plugin.cc:
The type of a pointer to a function must be compatible with the
pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
The variable buf pointer to pointer to pointer to constant char
could improperly alias a incompatible type in call to fix_type_
pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
Remove call to get_form_pos. The code creates a new FRM file which
is always truncated and writes the form position as 0. Hence, no
need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
Read weight directly from the buffer.
storage/myisam/fulltext.h:
Add explanation about the type duality of a key buffer.
Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
Read weight directly from the buffer.
storage/myisam/myisamchk.c:
Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
A pointer to char was used to alias a pointer to pointer to
unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
Remove now-unnecessary casts.
strings/decimal.c:
Remove aliasing violation, printing the value is enough for
debugging purposes.
tests/mysql_client_test.c:
Remove now-unnecessary casts.
Addendum: Work around a compilation failure on Windows due to
windows.h not being added to the global namespace.
extra/yassl/include/lock.hpp:
Move windows.h inclusion into the global namespace.
config/ac-macros/ssl.m4:
Enable yaSSL thread safety if linking with the server or a
thread safe client library. Avoids building a thread safe
yaSSL when only building a non-thread safe client library.
The problem was that the bundled yaSSL library was being built
without thread safety support regardless of the thread safeness
of the compoments linked with it.
The solution is to enable yaSSL thread safety support if any
component (server or client) is to be built with thread support.
Also, generate new certificates for yaSSL's test suite.
config/ac-macros/yassl.m4:
Enable yaSSL thread safety if linking with the server or a
thread safe client library. Avoids building a thread safe
yaSSL when only building a non-thread safe client library.
extra/yassl/CMakeLists.txt:
Always enable for Windows builds.
extra/yassl/certs/ca-cert.pem:
New certificate, previous one expired.
extra/yassl/certs/client-cert.der:
New certificate, previous one expired.
extra/yassl/certs/client-cert.pem:
New certificate, previous one expired.
extra/yassl/certs/dsa-cert.pem:
New certificate, previous one expired.
extra/yassl/certs/server-cert.pem:
New certificate, previous one expired.
extra/yassl/include/lock.hpp:
Rename MULTI_THREAD to YASSL_THREAD_SAFE.
extra/yassl/src/Makefile.am:
Use CXXFLAGS to set thread related definitions as the lock header
(lock.hpp) has no local dependencies.
extra/yassl/src/lock.cpp:
Rename MULTI_THREAD to YASSL_THREAD_SAFE.
extra/yassl/taocrypt/CMakeLists.txt:
Always enable for Windows builds.
extra/yassl/taocrypt/benchmark/Makefile.am:
Pass thread related CXXFLAGS.
extra/yassl/taocrypt/src/Makefile.am:
Pass thread related CXXFLAGS.
extra/yassl/taocrypt/test/Makefile.am:
Pass thread related CXXFLAGS.
extra/yassl/taocrypt/test/memory.cpp:
Rename MULTI_THREAD to YASSL_THREAD_SAFE.
extra/yassl/testsuite/Makefile.am:
Pass thread related CXXFLAGS.
MySQL with gcc 4.3.2
This is the final patch in the context of this bug.
cmd-line-utils/readline/rlmbutil.h:
Changed in a previous patch, reverted by a backport.
cmd-line-utils/readline/text.c:
Static var initialization.
extra/yassl/include/yassl_error.hpp:
SetErrorString handles errors outside of the YasslError
enum.
extra/yassl/src/ssl.cpp:
SetErrorString handles errors outside of the YasslError
enum.
extra/yassl/src/yassl_error.cpp:
SetErrorString handles errors outside of the YasslError
enum.
Problem: copying issuer's (or subject's) name tags into an internal
buffer from incoming stream we didn't check the buffer overflow.
That may lead to memory overrun, crash etc.
Fix: ensure we don't overrun the buffer.
Note: there's no simple test case (exploit needed).
extra/yassl/taocrypt/include/asn.hpp:
Fix for bug#50227: Pre-auth buffer-overflow in mySQL through yaSSL
- CertDecoder::AddTag() introduced.
extra/yassl/taocrypt/src/asn.cpp:
Fix for bug#50227: Pre-auth buffer-overflow in mySQL through yaSSL
- copying data from incoming stream to the issuer_ or subject_
buffers ensure we don't overrun them.
- code cleanup.
Fixed 2 errors in comp_err executable :
1. Wrong (off by 1) length passed to my_checksum()
2. strmov() was used on overlapping strings. This is
not legal according to the docs in stpcpy(). Used
the overlap safe memmove() instead.
it returns misleading 'table is full'
Innodb returns a misleading error message "table is full"
when the number of active concurrent transactions is greater
than 1024.
Fixed by adding errorcode "ER_TOO_MANY_CONCURRENT_TRXS" to the
error codes. Innodb should return HA_TOO_MANY_CONCURRENT_TRXS
to mysql which is then mapped to ER_TOO_MANY_CONCURRENT_TRXS
Note: testcase is not written as this was reproducible only by
changing innodb code.
extra/perror.c:
Add error number and message for HA_ERR_TOO_MANY_CONCURRENT_TRXS
include/my_base.h:
Add error number and message for HA_ERR_TOO_MANY_CONCURRENT_TRXS
sql/ha_innodb.cc:
Return HA_ERR_TOO_MANY_CONCURRENT_TRXS to mysql server
sql/handler.cc:
Add error number and message for HA_ERR_TOO_MANY_CONCURRENT_TRXS
sql/share/errmsg.txt:
Add error message for ER_TOO_MANY_CONCURRENT_TRXS
Add all HA error numbers and descriptions to perror.
Add reminder to header.
This is already fixed in smarter ways in future codebases, and this
codebase is unlikely to change, since new development is forbidden
here.
- Remove bothersome warning messages. This change focuses on the warnings
that are covered by the ignore file: support-files/compiler_warnings.supp.
- Strings are guaranteed to be max uint in length
- Remove bothersome warning messages. This change focuses on the warnings
that are covered by the ignore file: support-files/compiler_warnings.supp.
- Strings are guaranteed to be max uint in length
resolve_stack_dump is not able to decode a stack trace produced
by glibc's backtrace() functions. The problem is that the stack
trace addresses are printed between brackets and the utility is
not able to ignore the brackets.
The solution is to modify resolve_stack_dump so it can recognize
stack trace addresses surrounded by brackets. e.g. [0xdeadbeef].
extra/resolve_stack_dump.c:
Skip to after a bracket if one is present in the input.
with non-RSA-requesting client if server uses RSA key
matchSuite() may not find a match.
It will return error in this case.
Added a error checking code that will prevent using uninitialized
memory in the code based on the assumption
that matchSuite() has found a match.
extra/yassl/src/yassl_imp.cpp:
Bug #39178: Correct error checking added
extended perror to enable printing of Win32 system errors
extra/perror.c:
extended perror to enable printing of Win32 system errors
mysql-test/r/perror-win.result:
test result
mysql-test/t/perror-win.test:
test case
using crashes server
When the server is configured to use a RSA key, and when the client sends
a cipher-suite list that contains a non-RSA key as acceptable, the server
would try to process that key even though it was impossible.
Now, yaSSL sets its own acceptable-cipher list according to what kind of
key the server is started with, and will never explore and try to pair
impossible combinations.
This involves a partial import of the current YaSSL tree, not the whole
thing, so as to try to avoid introducing new bugs.
(Updated to avoid many whitespace changes and make diff smaller.)
Merge it up from 5.0 to 5.1,
adapt to some version differences.
configure.in:
Add an "automake condition" whether InnoDB is configured
so that we can evaluate it for the (non)generation of "innochecksum".
In 5.1, the test command must differ from 5.0.
Mostly, this affected files (programs, scripts, and manual pages)
which got built during a RPM build but were not listed in the
appropriate "%files" section of the "spec" file.
This is fixed now, they are added.
To make this consistent, this patch also makes the build of "innochecksum"
(and its inclusion in a tar.gz or other package) depend on whether InnoDB
is configured in the build.
Also, some tools to create Windows packages are irrelevant in any binary
Unix package (not the sources !), and so they are deleted before packaging.
configure.in:
To prevent "innochecksum" from getting built even if InnoDB is not configured
(and then being included in such packages),
we need an "automake condition" that evaluates whether we have InnoDB.
extra/Makefile.am:
Evaluate the new automake condition about having InnoDB,
and make the build of "innochecksum" depend on it.
man/Makefile.am:
Cleanup: There are manual files which we do not need,
like those about tools for Windows builds / packaging
(irrelevant in any Unix binary package)
and about NDB tools which do not get built.
scripts/make_binary_distribution.sh:
In any Unix binary package, do not include tools for Windows builds
(and their manual pages).
This does not affect source packages, of course.
support-files/mysql.spec.sh:
There were several files (binaries, scripts, and manuals)
which got built with a RPM but never packages,
add them to the respective RPM.
- Cherry pick 6.0 changes for Visual Studio 2008 support
- Add scripts win\build-vs9.bat and win\build-vs9_x64.bat
Also, remove CMake generated visual studio project files.
extra/yassl/taocrypt/taocrypt.vcproj:
remove file that is generated each time by cmake
extra/yassl/yassl.vcproj:
remove file that is generated each time by cmake
server-tools/instance-manager/mysqlmanager.vcproj:
remove file that is generated each time by cmake
win/build-vs9.bat:
Add script for Visual Studio 2008 support
win/build-vs9_x64.bat:
Add script for Visual Studio 2008 support
zlib/zutil.h:
support Visual Studio 2008
in perror and handler descriptors (BUG#25177)
Fixed problem of masking mysql error by system
error in perror (BUG#23028)
extra/perror.c:
Used common handlers error list.
Fixed BUG#23028 ignoring mysql error in case of
OS and mysql error codes overlapping.
include/my_base.h:
Added errors of maria engine.
Fixed incorrect comment in #define (can be cause of
seriouse problems)
include/my_handler.h:
Added ability to be included into C++ code.
mysys/my_handler.c:
Error texts moved to the separate files.
mysys/my_handler_errors.h:
New BitKeeper file ``mysys/my_handler_errors.h''
into gbichot4.local:/home/mysql_src/mysql-5.1-build-gca
client/mysqltest.c:
Auto merged
include/my_sys.h:
Auto merged
mysys/thr_lock.c:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_plugin.cc:
Auto merged
value" error even though the value was correct): a C function in my_getopt.c
was taking bool* in parameter and was called from C++ sql_plugin.cc,
but on some Mac OS X sizeof(bool) is 1 in C and 4 in C++, giving funny
mismatches. Fixed, all other occurences of bool in C are removed, future
ones are blocked by a "C-bool-catcher" in my_global.h (use my_bool).
client/mysqldump.c:
my_bool for C
client/mysqltest.c:
my_bool for C
extra/replace.c:
my_bool for C
include/my_getopt.h:
my_bool for C
include/my_global.h:
Prevent people from using bool in C, it causes real bugs.
include/my_sys.h:
my_bool for C
include/my_time.h:
my_bool for C
include/thr_lock.h:
my_bool for C
libmysql/libmysql.c:
my_bool for C
mysys/charset.c:
my_bool for C
mysys/my_getopt.c:
my_bool for C
mysys/queues.c:
my_bool for C
mysys/thr_lock.c:
my_bool for C
regex/reginit.c:
my_bool for C
sql/set_var.cc:
C functions use my_bool so we must use my_bool too.
sql/sql_plugin.cc:
C functions use my_bool so we must use my_bool too.
This fixes a real observed bug of Maria, because on some Mac OS X,
sizeof(bool) is 1 in C and 4 in C++, so the bool* does wrong.
Removing useless line.
storage/heap/hp_update.c:
my_bool for C
storage/myisam/mi_check.c:
my_bool for C
storage/myisam/mi_dynrec.c:
my_bool for C
storage/myisam/mi_search.c:
my_bool for C
storage/myisam/mi_update.c:
my_bool for C
storage/myisam/mi_write.c:
my_bool for C
storage/myisam/myisamdef.h:
my_bool for C
storage/myisam/myisamlog.c:
my_bool for C
storage/myisam/myisampack.c:
my_bool for C
tests/mysql_client_test.c:
my_bool for C
unittest/mysys/bitmap-t.c:
my_bool for C
vio/viosslfactories.c:
my_bool for C
extra/resolveip.c:
Regrettably, Windows does not have inet_aton. We still don't want to use inet_addr on all platforms, because it is inaccurate and deprecated on many.
into trift2.:/MySQL/M51/push-5.1
configure.in:
Auto merged
extra/CMakeLists.txt:
Auto merged
extra/resolveip.c:
Auto merged
mysql-test/t/disabled.def:
Auto merged
into zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.1-maint
configure.in:
Auto merged
extra/resolveip.c:
Auto merged
include/my_sys.h:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/r/ctype_ucs.result:
Auto merged
mysql-test/r/func_misc.result:
Auto merged
mysql-test/t/ctype_ucs.test:
Auto merged
mysql-test/t/func_misc.test:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_cmpfunc.h:
Auto merged
sql/item_strfunc.h:
Auto merged
sql/item_timefunc.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/set_var.h:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_table.cc:
Auto merged
storage/myisam/ft_boolean_search.c:
Auto merged
storage/myisam/ha_myisam.cc:
Auto merged
storage/myisam/sort.c:
Auto merged
client/mysqlcheck.c:
manual merge
mysql-test/r/mysqlcheck.result:
manual merge
mysql-test/t/mysqlcheck.test:
manual merge
Patch by Kasper Dupont. No CLA required for this size of patch.
"resolveip" program produces incorrect result if given a hostname
starting with a digit. Someone seems to have thought that names
can not have digits at the beginning.
Instead, use the resolver library to work out the rules of hostnames,
as it will undoubtedly be better at it than we are.
configure.in:
See if we need to a library for address lookups.
extra/resolveip.c:
Don't use silly heuristic to know whether a string is a dotted
quad. Instead, pass the whole thing into the resolver and let
its smarts do all the work.
into pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.1-build
configure.in:
Auto merged
extra/yassl/src/template_instnt.cpp:
Auto merged
extra/yassl/src/yassl_imp.cpp:
Auto merged