You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
6.5 KiB

26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled Essentially, the problem is that safemalloc is excruciatingly slow as it checks all allocated blocks for overrun at each memory management primitive, yielding a almost exponential slowdown for the memory management functions (malloc, realloc, free). The overrun check basically consists of verifying some bytes of a block for certain magic keys, which catches some simple forms of overrun. Another minor problem is violation of aliasing rules and that its own internal list of blocks is prone to corruption. Another issue with safemalloc is rather the maintenance cost as the tool has a significant impact on the server code. Given the magnitude of memory debuggers available nowadays, especially those that are provided with the platform malloc implementation, maintenance of a in-house and largely obsolete memory debugger becomes a burden that is not worth the effort due to its slowness and lack of support for detecting more common forms of heap corruption. Since there are third-party tools that can provide the same functionality at a lower or comparable performance cost, the solution is to simply remove safemalloc. Third-party tools can provide the same functionality at a lower or comparable performance cost. The removal of safemalloc also allows a simplification of the malloc wrappers, removing quite a bit of kludge: redefinition of my_malloc, my_free and the removal of the unused second argument of my_free. Since free() always check whether the supplied pointer is null, redudant checks are also removed. Also, this patch adds unit testing for my_malloc and moves my_realloc implementation into the same file as the other memory allocation primitives.
16 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
26 years ago
  1. #!/bin/sh
  2. # Copyright (C) 2000-2006 MySQL AB
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; version 2 of the License.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. # This script reports various configuration settings that may be needed
  17. # when using the MySQL client library.
  18. which ()
  19. {
  20. IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
  21. for file
  22. do
  23. for dir in $PATH
  24. do
  25. if test -f $dir/$file
  26. then
  27. echo "$dir/$file"
  28. continue 2
  29. fi
  30. done
  31. echo "which: no $file in ($PATH)"
  32. exit 1
  33. done
  34. IFS="$save_ifs"
  35. }
  36. #
  37. # If we can find the given directory relatively to where mysql_config is
  38. # we should use this instead of the incompiled one.
  39. # This is to ensure that this script also works with the binary MySQL
  40. # version
  41. fix_path ()
  42. {
  43. var=$1
  44. shift
  45. for filename
  46. do
  47. path=$basedir/$filename
  48. if [ -d "$path" ] ;
  49. then
  50. eval "$var"=$path
  51. return
  52. fi
  53. done
  54. }
  55. get_full_path ()
  56. {
  57. file=$1
  58. # if the file is a symlink, try to resolve it
  59. if [ -h $file ];
  60. then
  61. file=`ls -l $file | awk '{ print $NF }'`
  62. fi
  63. case $file in
  64. /*) echo "$file";;
  65. */*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
  66. *) which $file ;;
  67. esac
  68. }
  69. me=`get_full_path $0`
  70. basedir=`echo $me | sed -e 's;/bin/mysql_config;;'`
  71. ldata='@localstatedir@'
  72. execdir='@libexecdir@'
  73. bindir='@bindir@'
  74. # If installed, search for the compiled in directory first (might be "lib64")
  75. pkglibdir='@pkglibdir@'
  76. pkglibdir_rel=`echo $pkglibdir | sed -e "s;^$basedir/;;"`
  77. fix_path pkglibdir $pkglibdir_rel lib/mysql lib
  78. plugindir='@pkgplugindir@'
  79. plugindir_rel=`echo $plugindir | sed -e "s;^$basedir/;;"`
  80. fix_path plugindir $plugindir_rel lib/mysql/plugin lib/plugin
  81. pkgincludedir='@pkgincludedir@'
  82. fix_path pkgincludedir include/mysql include
  83. version='@VERSION@'
  84. socket='@MYSQL_UNIX_ADDR@'
  85. ldflags='@LDFLAGS@'
  86. if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then
  87. port=0
  88. else
  89. port=@MYSQL_TCP_PORT@
  90. fi
  91. # Create options
  92. # We intentionally add a space to the beginning and end of lib strings, simplifies replace later
  93. libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
  94. libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@ "
  95. libs_r=" $ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @CLIENT_LIBS@ @openssl_libs@ "
  96. embedded_libs=" $ldflags -L$pkglibdir -lmysqld @LIBDL@ @ZLIB_DEPS@ @LIBS@ @WRAPLIBS@ @openssl_libs@ "
  97. if [ -r "$pkglibdir/libmygcc.a" ]; then
  98. # When linking against the static library with a different version of GCC
  99. # from what was used to compile the library, some symbols may not be defined
  100. # automatically. We package the libmygcc.a from the build host, to provide
  101. # definitions for those. Bugs 4921, 19561, 19817, 21158, etc.
  102. libs="$libs -lmygcc "
  103. libs_r="$libs_r -lmygcc "
  104. embedded_libs="$embedded_libs -lmygcc "
  105. fi
  106. cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
  107. include="-I$pkgincludedir"
  108. # Remove some options that a client doesn't have to care about
  109. # FIXME until we have a --cxxflags, we need to remove -Xa
  110. # and -xstrconst to make --cflags usable for Sun Forte C++
  111. # FIXME until we have a --cxxflags, we need to remove -AC99
  112. # to make --cflags usable for HP C++ (aCC)
  113. for remove in DDBUG_OFF DSAFE_MUTEX DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
  114. DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
  115. 'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
  116. Xa xstrconst "xc99=none" AC99 \
  117. unroll2 ip mp restrict
  118. do
  119. # The first option we might strip will always have a space before it because
  120. # we set -I$pkgincludedir as the first option
  121. cflags=`echo "$cflags"|sed -e "s/ -$remove */ /g"`
  122. done
  123. cflags=`echo "$cflags"|sed -e 's/ *\$//'`
  124. # Same for --libs(_r)
  125. for remove in lmtmalloc static-libcxa i-static static-intel
  126. do
  127. # We know the strings starts with a space
  128. libs=`echo "$libs"|sed -e "s/ -$remove */ /g"`
  129. libs_r=`echo "$libs_r"|sed -e "s/ -$remove */ /g"`
  130. embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove */ /g"`
  131. done
  132. # Strip trailing and ending space if any, and '+' (FIXME why?)
  133. libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  134. libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  135. embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
  136. usage () {
  137. cat <<EOF
  138. Usage: $0 [OPTIONS]
  139. Options:
  140. --cflags [$cflags]
  141. --include [$include]
  142. --libs [$libs]
  143. --libs_r [$libs_r]
  144. --plugindir [$plugindir]
  145. --socket [$socket]
  146. --port [$port]
  147. --version [$version]
  148. --libmysqld-libs [$embedded_libs]
  149. --variable=VAR VAR is one of:
  150. pkgincludedir [$pkgincludedir]
  151. pkglibdir [$pkglibdir]
  152. plugindir [$plugindir]
  153. EOF
  154. exit 1
  155. }
  156. if test $# -le 0; then usage; fi
  157. while test $# -gt 0; do
  158. case $1 in
  159. --cflags) echo "$cflags" ;;
  160. --include) echo "$include" ;;
  161. --libs) echo "$libs" ;;
  162. --libs_r) echo "$libs_r" ;;
  163. --plugindir) echo "$plugindir" ;;
  164. --socket) echo "$socket" ;;
  165. --port) echo "$port" ;;
  166. --version) echo "$version" ;;
  167. --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
  168. --variable=*)
  169. var=`echo "$1" | sed 's,^[^=]*=,,'`
  170. case "$var" in
  171. pkgincludedir) echo "$pkgincludedir" ;;
  172. pkglibdir) echo "$pkglibdir" ;;
  173. plugindir) echo "$plugindir" ;;
  174. *) usage ;;
  175. esac
  176. ;;
  177. *) usage ;;
  178. esac
  179. shift
  180. done
  181. #echo "ldata: '"$ldata"'"
  182. #echo "execdir: '"$execdir"'"
  183. #echo "bindir: '"$bindir"'"
  184. #echo "pkglibdir: '"$pkglibdir"'"
  185. #echo "pkgincludedir: '"$pkgincludedir"'"
  186. #echo "version: '"$version"'"
  187. #echo "socket: '"$socket"'"
  188. #echo "port: '"$port"'"
  189. #echo "ldflags: '"$ldflags"'"
  190. #echo "client_libs: '"$client_libs"'"
  191. exit 0