anjaniravi / memcached

Automatically exported from code.google.com/p/memcached
0 stars 0 forks source link

make error "array subscript is above array bounds" for v>=1.4.5 on Opensuse (upstream bug) #219

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
lsb_release -rd
    Description:    openSUSE 11.4 (i586)
    Release:        11.4
uname -sr
    Linux 2.6.37.6-0.7-default
gcc -v
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/i586-suse-linux/4.5/lto-wrapper
    Target: i586-suse-linux
    Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.5 --enable-linux-futex --without-system-libunwind --enable-gold --with-plugin-ld=/usr/bin/gold --with-arch-32=i586 --with-tune=generic --build=i586-suse-linux
    Thread model: posix
    gcc version 4.5.3 20110428 [gcc-4_5-branch revision 173117] (SUSE Linux)

cd /usr/local/src
rm -rf memcached*
setenv MEMC_VER "1.4.7"
wget http://memcached.googlecode.com/files/memcached-${MEMC_VER}.tar.gz
tar zxvf memcached*gz

cd /usr/local/src/memcached*/
./configure
make
    make  all-recursive
    make[1]: Entering directory `/usr/local/src/memcached-1.4.7'
    Making all in doc
    make[2]: Entering directory `/usr/local/src/memcached-1.4.7/doc'
    make  all-am
    make[3]: Entering directory `/usr/local/src/memcached-1.4.7/doc'
    make[3]: Nothing to be done for `all-am'.
    make[3]: Leaving directory `/usr/local/src/memcached-1.4.7/doc'
    make[2]: Leaving directory `/usr/local/src/memcached-1.4.7/doc'
    make[2]: Entering directory `/usr/local/src/memcached-1.4.7'
    gcc -std=gnu99 -DHAVE_CONFIG_H -I.  -DNDEBUG   -O2 -mtune=generic -march=native -pthread -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -MT memcached-memcached.o -MD -MP -MF .deps/memcached-memcached.Tpo -c -o memcached-memcached.o `test -f 'memcached.c' || echo './'`memcached.c
    cc1: warnings being treated as errors
    memcached.c: In function ‘try_read_command’:
    memcached.c:2359:9: error: array subscript is above array bounds
    memcached.c:2359:9: error: array subscript is above array bounds
    memcached.c:2363:14: error: array subscript is above array bounds
    memcached.c:2363:14: error: array subscript is above array bounds
    memcached.c:2363:14: error: array subscript is above array bounds
    make[2]: *** [memcached-memcached.o] Error 1
    make[2]: Leaving directory `/usr/local/src/memcached-1.4.7'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/usr/local/src/memcached-1.4.7'
    make: *** [all] Error 2

applying a found patch 
(https://svn.erp5.org/repos/public/erp5/trunk/patches/memcached-1.4-fix-array-su
bscript-is-above-array-bounds.patch) seems to remedy the problem,

cat fix-array-subscript-is-above-array-bounds.patch
    # zypper si memcached
    # cat /usr/src/packages/SOURCES/memcached-1.4.5.dif

    --- memcached.c.orig    2011-07-12 00:37:00.000000000 -0700
    +++ memcached.c 2011-07-17 20:14:53.000000000 -0700
    @@ -2360,15 +2360,18 @@
     inline static void process_stats_detail(conn *c, const char *command) {
         assert(c != NULL);

    -    if (strcmp(command, "on") == 0) {
    +    char on[] = "on";
    +    char off[] = "off";
    +    char dump[] = "dump";
    +    if (strcmp(command, on) == 0) {
             settings.detail_enabled = 1;
             out_string(c, "OK");
         }
    -    else if (strcmp(command, "off") == 0) {
    +    else if (strcmp(command, off) == 0) {
             settings.detail_enabled = 0;
             out_string(c, "OK");
         }
    -    else if (strcmp(command, "dump") == 0) {
    +    else if (strcmp(command, dump) == 0) {
             int len;
             char *stats = stats_prefix_dump(&len);
             write_and_free(c, stats, len);

cd /usr/local/src/memcached*/
make clean
patch -p0 < ../fix-array-subscript-is-above-array-bounds.patch
    patching file memcached.c
    Hunk #1 succeeded at 2356 (offset -4 lines).
./configure
make
    ...
    make[2]: Leaving directory `/usr/local/src/memcached-1.4.7'
    make[1]: Leaving directory `/usr/local/src/memcached-1.4.7'
    >
make install
ls -al `which memcached`
    -rwxr-xr-x 1 root root 93136 Aug 21 13:34 /usr/local/bin/memcached

Original issue reported on code.google.com by b8451349@klzlk.com on 21 Aug 2011 at 8:39

GoogleCodeExporter commented 9 years ago
This patch makes super little sense to me. Why would it fail on that section, 
but not the ten other areas which have the same exact code? Don't see this 
error on any other platforms as well.

I'd like to sit down with a suse instance and play with it. I don't have one 
nor does my KVM setup work at the moment, so I'm going to punt for 1.4.9. If 
you or someone has a shell I can use to fiddle, I'd take a look.

Original comment by dorma...@rydia.net on 28 Sep 2011 at 4:51

GoogleCodeExporter commented 9 years ago
Issue 223 has been merged into this issue.

Original comment by dsalli...@gmail.com on 28 Sep 2011 at 8:49

GoogleCodeExporter commented 9 years ago
We're going to declare this a WONTFIX, but leave it open for others to 
understand what the issue is.

This appears to be a compiler bug affecting OpenSuse.  There are many 
references to it in other projects, all of which have dumb workarounds we'd 
rather not do.  We've seen memcached compile with any one of these three things:

 * Manually create char arrays for this function as shown in this patch.
 * Make this function not be static/inline.
 * Disable gcc optimizations (change -O2 to -O0 )

If the code fails to compile on one or two platforms because of a bug in the 
compiler and the workarounds aren't clean (either reducing performance in the 
latter two or just making things confusing in the first one), we'd rather just 
wait for the upstream to fix their bugs.

This bug will be left open until the vendor distributes a fix for their bug, 
and then close it as wontfix.  Simple workarounds are welcome here, but if the 
code isn't wrong, we'd rather not fix it.

Tested good on:

  GCC 4.5.3 / FreeBSD
  GCC 4.6.1 / debian
  GCC 4.6.0 / fedora
  GCC 4.5.2  / ubuntu
  clang 2.1 / OS X Lion

Original comment by dsalli...@gmail.com on 28 Sep 2011 at 9:35

GoogleCodeExporter commented 9 years ago
Issue 228 has been merged into this issue.

Original comment by dorma...@gmail.com on 15 Nov 2011 at 5:03