Bug #48864 MySQL fails to compile on 64 bit Fedora 12
Submitted: 18 Nov 2009 13:39 Modified: 18 Jun 2010 1:16
Reporter: Georgi Kodinov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.0, 5.1 OS:Linux (Fedora 12 x86_64)
Assigned to: Georgi Kodinov CPU Architecture:Any

[18 Nov 2009 13:39] Georgi Kodinov
Description:
I've just installed Fedora 12 and mysql fails to compile on it : 
../extra/comp_err \
        --charset=../sql/share/charsets \
        --out-dir=../sql/share/ \
        --header_file=../include/mysqld_error.h \
        --name_file=../include/mysqld_ername.h \
        --state_file=../include/sql_state.h \
        --in_file=../sql/share/errmsg.txt
Wrong formatspecifier of error message string for error 'ER_UNEXPECTED_EOF' in language 'jps'

Looking on the code it seems like comp_err is plain wrong : 
In parse_text_line() it's using strmov(pos - 1, pos) 
In linux this maps to stpcpy()
And according to the manual 
" The  stpcpy() function copies the string pointed to by src (including the terminating '\0' character) to
       the array pointed to by dest.  The strings may not overlap, and the  destination  string  dest  must  be
       large enough to receive the copy."

Look how it explicitly says that the strings *may not* overlap. 

Here's some version info : 
gcc (GCC) 4.4.2 20091027 (Red Hat 4.4.2-7)
GNU C Library stable release version 2.11, by Roland McGrath et al

How to repeat:
BUILD/compile-pentium-debug-max 

Suggested fix:
Use the appropriate string function in comp_err
[18 Nov 2009 15:24] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/90878

2847 Georgi Kodinov	2009-11-18
      Bug#48864: MySQL fails to compile on 64 bit Fedora 12
      
      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.
[19 Nov 2009 9:32] Georgi Kodinov
Here's how the fellow Redhat developers are solving this problem in the stock 5.1.39 source RPM they're distributing. I find it fascinating. 

mysql-strmov.patch

  1 Remove overly optimistic definition of strmov() as stpcpy().
  2 
  3 mysql uses this macro with overlapping source and destination strings,
  4 which is verboten per spec, and fails on some Red Hat platforms.
  5 Deleting the definition is sufficient to make it fall back to a
  6 byte-at-a-time copy loop, which should consistently give the
  7 expected behavior.
  8 
  9 
 10 diff -Naur mysql-5.1.37.orig/include/m_string.h mysql-5.1.37/include/m_string.h
 11 --- mysql-5.1.37.orig/include/m_string.h        2009-07-13 19:08:50.000000000 -0400
 12 +++ mysql-5.1.37/include/m_string.h     2009-08-31 21:49:49.000000000 -0400
 13 @@ -81,13 +81,6 @@
 14  extern void *(*my_str_malloc)(size_t);
 15  extern void (*my_str_free)(void *);
 16 
 17 -#if defined(HAVE_STPCPY)
 18 -#define strmov(A,B) stpcpy((A),(B))
 19 -#ifndef stpcpy
 20 -extern char *stpcpy(char *, const char *);     /* For AIX with gcc 2.95.3 */
 21 -#endif
 22 -#endif
 23 -
 24  /* Declared in int2str() */
 25  extern char NEAR _dig_vec_upper[];
 26  extern char NEAR _dig_vec_lower[];
[2 Dec 2009 8:01] Bugs System
Pushed into 5.0.89 (revid:joro@sun.com-20091202075830-mzl79q7mc1v72pf1) (version source revid:joro@sun.com-20091118152410-j4tv22vf9xkb6sdz) (merge vers: 5.0.88) (pib:13)
[2 Dec 2009 8:07] Bugs System
Pushed into 5.1.42 (revid:joro@sun.com-20091202080033-mndu4sxwx19lz2zs) (version source revid:davi.arnaut@sun.com-20091125130912-d7hrln14ef7y5d7i) (merge vers: 5.1.42) (pib:13)
[7 Dec 2009 13:59] MC Brown
An entry has been added to the 5.0.89 and 5.1.42 changelogs: 

Building MySQL on Fedora Core 12 64-bit would due to errors in comp_err
[16 Dec 2009 8:40] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091216083311-xorsasf5kopjxshf) (version source revid:alik@sun.com-20091214191830-wznm8245ku8xo702) (merge vers: 6.0.14-alpha) (pib:14)
[16 Dec 2009 8:47] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091216082430-s0gtzibcgkv4pqul) (version source revid:alexey.kopytov@sun.com-20091124083136-iqm136jm31sfdwg3) (merge vers: 5.5.0-beta) (pib:14)
[16 Dec 2009 8:54] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20091216083231-rp8ecpnvkkbhtb27) (version source revid:alik@sun.com-20091212203859-fx4rx5uab47wwuzd) (merge vers: 5.6.0-beta) (pib:14)
[17 Dec 2009 10:55] MC Brown
A changelog entry has been added to the 5.5.1 and 6.0.14 chnagelogs
[17 Feb 2010 16:28] Paul DuBois
Noted in 5.0.87sp1 changelog.
[20 Feb 2010 17:11] Bugs System
Pushed into 5.0.91 (revid:build@mysql.com-20100220170835-5kr6ztsg25va7qzz) (version source revid:build@mysql.com-20100220170835-5kr6ztsg25va7qzz) (merge vers: 5.0.91) (pib:16)
[1 Mar 2010 8:46] Bugs System
Pushed into 5.1.45 (revid:joro@sun.com-20100301083827-xnimmrjg6bh33o1o) (version source revid:joro@sun.com-20100226131646-kpvzk740hxbtaexn) (merge vers: 5.1.45) (pib:16)
[1 Mar 2010 14:32] MC Brown
A note has been added to the 5.0.91 and 5.1.45 changelogs
[2 Mar 2010 14:36] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100302142746-u1gxdf5yk2bjrq3e) (version source revid:alik@sun.com-20100301095421-4cz64ibem1h2quve) (merge vers: 6.0.14-alpha) (pib:16)
[2 Mar 2010 14:41] Bugs System
Pushed into 5.5.3-m2 (revid:alik@sun.com-20100302072233-t3uqgjzdukt1pyhe) (version source revid:alik@sun.com-20100301090215-63o2w2y16go8n53p) (merge vers: 5.5.3-m2) (pib:16)
[2 Mar 2010 14:46] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100302072432-k8xvfkgcggkwgi94) (version source revid:alik@sun.com-20100301094536-2zc4uqyy3os8san7) (pib:16)
[2 Mar 2010 14:58] MC Brown
Updated changelog versions for 5.5.3 and 6.0.14
[12 Mar 2010 14:15] Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:31] Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:42] MC Brown
No changelog entry required.
[12 Mar 2010 14:47] Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)
[12 Mar 2010 15:42] MC Brown
No changelog entry needed.
[17 Jun 2010 11:59] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 12:39] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:martin.skold@mysql.com-20100609140708-52rvuyq4q500sxkq) (merge vers: 5.1.45-ndb-6.2.19) (pib:16)
[17 Jun 2010 13:25] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[14 Nov 2013 14:12] Paul DuBois
Noted in 5.7.3 changelog:

Fixed a potential problem with the MySQL string function strmov().
Its behavior with respect to overlap of source and destination
previously depended on native support for stpcpy().