Bug #36703 Unknown symbol EncodedDataStream::decode when linking mysqld with Sun Studio
Submitted: 13 May 2008 23:52 Modified: 9 Oct 2008 12:54
Reporter: Olav Sandstaa Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Falcon storage engine Severity:S3 (Non-critical)
Version:6.0.6 OS:Solaris
Assigned to: Olav Sandstå CPU Architecture:Any
Tags: Sun Studio
Triage: D1 (Critical)

[13 May 2008 23:52] Olav Sandstaa
When compiling MySQL based on the mysql-6.0-falcon-team tree I get the following linking error when linking mysqld:

Undefined                       first referenced
 symbol                             in file
const unsigned char*EncodedDataStream::decode(const unsigned char*,Value*,bool) ../storage/falcon/libfalcon.a(libhafalcon_a-TableSpaceManager.o)
ld: fatal: Symbol referencing errors. No output written to mysqld

How to repeat:
Check out the source from mysql-6.0-falcon-team tree and compile it using Sun Studio compiler on Solaris.

Suggested fix:
Fix the source code that produces this problem.
[14 May 2008 1:44] Olav Sandstå
Using nm to get the symbol information from the libhafalcon_a-EncodedDataStream.o I get the following for the "undefined" function:

[69]    |      8472|    3024|FUNC |GLOB |0    |2      |const unsigned char*EncodedDataStream::decode(const unsigned char*,Value*,bool)

Doing the same on the libhafalcon_a-TableSpaceManager.o file I see:

[56]    |         0|       0|FUNC |GLOB |0    |UNDEF  |const unsigned char*EncodedDataStream::decode(const unsigned char*,Value*,bool)

Based on this it seems like the function is included in the correct object file and the demangled versions seems identical but the "non-mangled"(?) name seems to differ on the last 2-3 characters.
[14 May 2008 4:11] Valeriy Kravchuk
Thank you for a problem report. What exact versions of Solaris and Sun Studio were used?
[16 May 2008 13:49] Olav Sandstå
Solaris version used: Solaris 10 update 5:

                         Solaris 10 5/08 s10s_u5wos_10 SPARC
           Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                             Assembled 24 March 2008

Compiler version used: Sun Studio 12:

os136802@techra29:> /opt/studio12/SUNWspro/bin/CC -V
CC: Sun C++ 5.9 SunOS_sparc Patch 124863-02 2007/12/18
[29 May 2008 13:55] Olav Sandstå
In EncodedDataStream.h the decode() method have the following signature:

    static const unsigned char* decode (const unsigned char *ptr, Value *value, bool copyFlag);

In the implementation in EncodedDataStream.cpp the decode() method have the following signature:

   const UCHAR* EncodedDataStream::decode(const UCHAR *ptr, Value *value, bool copyFlag)

Given that UCHAR has the following definition (in storage/falcon/Engine.h):

   typedef unsigned char  UCHAR;

the compiler is not complaining about this "difference". Still the Sun Studio 12 compiler gives this method a different symbol name in the object file compared the what it expects in the file that is calling the method.

Replacing the UCHAR with "unsigned char" in the signature for the decode() method in storage/falcon/DecodedDataStream.cpp above solves the linking problem. 

Unless anyone objects I will make a patch with this change. I am considering whether this should be reported as a Sun Studio compiler bug or not?
[29 May 2008 19:09] Hakan Küçükyılmaz

what about rewriting the signature to:

   static const UCHAR* decode (const unsigned char *ptr, Value *value, bool copyFlag);
[29 May 2008 19:19] Olav Sandstå
With the help from Wlad and Google this seems to be a known problem with the Sun Studio 12 C++ compiler. See:

[30 May 2008 10:09] 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:


2683 Olav Sandstaa	2008-05-30
      A fix for Bug#36703: Unknown symbol EncodedDataStream::decode when linking mysqld with Sun Studio
      The problem was due to Sun Studio compiler produced a different symbol names in the object files for the decode()
      method for the implementation of the method and when it was called.
      This was triggered due to that the declartion of the method used "unsigned char" while the definition of the method used a UCHAR (which is typedef unsigned char). 
      Fixed this problem by using UCHAR in both declaration and definition.
[30 May 2008 10:18] Olav Sandstå

Thanks for the suggestion to rewrite the declaration to use UCHAR instead of changing the definition to use "unsigned char". I have submitted a patch which does this. The "drawback" of this was that I also needed to include a new .h file (Engine.h) in the EncodedDataStream.h file.
[22 Aug 2008 19:21] Kevin Lewis
Fix is in version 6.0.7
[9 Oct 2008 12:54] Jon Stephens
Documented in the 6.0.7 changelog as follows:

        mysqld failed to build using the Sun Studio compiler.