Bug 185663 - [libcxxrt] Bug in the libcxxrt version in FreeBSD 10.0: _ZTIDn not implemented
Summary: [libcxxrt] Bug in the libcxxrt version in FreeBSD 10.0: _ZTIDn not implemented
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-11 17:40 UTC by Hongli Lai
Modified: 2018-01-30 01:16 UTC (History)
2 users (show)

See Also:
emaste: mfc-stable11+
emaste: mfc-stable10-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hongli Lai 2014-01-11 17:40:00 UTC
The libcxxrt library included in FreeBSD 10.0 has a bug: it does not implement the _ZTIDn symbol, which is an important part of the C++ standard. This causes compilation of certain software to fail. See http://llvm.org/bugs/show_bug.cgi?id=18310 and https://github.com/pathscale/libcxxrt/issues/16.

I am reporting this bug to bring this to your attention. Is it likely that the libcxxrt author will fix this bug in the near future. Please keep an eye on his progress and please include his bug fixes in FreeBSD 10.0 as soon possible.

How-To-Repeat: See https://github.com/pathscale/libcxxrt/issues/16
Comment 1 dfilter service freebsd_committer 2014-01-11 19:02:24 UTC
Author: theraven
Date: Sat Jan 11 19:02:17 2014
New Revision: 260553
URL: http://svnweb.freebsd.org/changeset/base/260553

Log:
  Add missing C++11 typeinfos to the libcxxrt version script.
  
  PR:		185663
  MFC after:	1 week

Modified:
  head/lib/libcxxrt/Version.map

Modified: head/lib/libcxxrt/Version.map
==============================================================================
--- head/lib/libcxxrt/Version.map	Sat Jan 11 18:56:48 2014	(r260552)
+++ head/lib/libcxxrt/Version.map	Sat Jan 11 19:02:17 2014	(r260553)
@@ -111,6 +111,19 @@ CXXABI_1.3 {
         "typeinfo for void";
         "typeinfo for wchar_t const*";
         "typeinfo for wchar_t";
+        # C++11 typeinfo not understood by our linker
+        # std::nullptr_t
+        _ZTIDn;_ZTIPDn;_ZTIPKDn;
+        # char16_t
+        _ZTIDi;_ZTIPDi;_ZTIPKDi;
+        # char32_t
+        _ZTIDs;_ZTIPDs;_ZTIPKDs;
+        # IEEE 754r decimal floating point
+        _ZTIDd;_ZTIPDd;_ZTIPKDd;
+        _ZTIDe;_ZTIPDe;_ZTIPKDe;
+        _ZTIDf;_ZTIPDf;_ZTIPKDf;
+        # IEEE 754r half-precision floating point
+        _ZTIDh;_ZTIPDh;_ZTIPKDh;
 
         "typeinfo for bool*";
         "typeinfo for wchar_t*";
@@ -195,6 +208,19 @@ CXXABI_1.3 {
         "typeinfo name for void*";
         "typeinfo name for unsigned int*";
         "typeinfo name for float*";
+        # C++11 typeinfo not understood by our linker
+        # std::nullptr_t
+        _ZTSDn;_ZTIPDn;_ZTIPKDn;
+        # char16_t
+        _ZTSDi;_ZTIPDi;_ZTIPKDi;
+        # char32_t
+        _ZTSDs;_ZTIPDs;_ZTIPKDs;
+        # IEEE 754r decimal floating point
+        _ZTSDd;_ZTIPDd;_ZTIPKDd;
+        _ZTSDe;_ZTIPDe;_ZTIPKDe;
+        _ZTSDf;_ZTIPDf;_ZTIPKDf;
+        # IEEE 754r half-precision floating point
+        _ZTSDh;_ZTIPDh;_ZTIPKDh;
 
         "typeinfo name for __cxxabiv1::__array_type_info";
         "typeinfo name for __cxxabiv1::__class_type_info";
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 2 dfilter service freebsd_committer 2014-02-09 00:34:35 UTC
Author: dim
Date: Sun Feb  9 00:34:21 2014
New Revision: 261644
URL: http://svnweb.freebsd.org/changeset/base/261644

Log:
  MFC r260553 (by theraven):
  
  Add missing C++11 typeinfos to the libcxxrt version script.
  
  PR:		185663

Modified:
  stable/10/lib/libcxxrt/Version.map
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libcxxrt/Version.map
==============================================================================
--- stable/10/lib/libcxxrt/Version.map	Sat Feb  8 23:54:16 2014	(r261643)
+++ stable/10/lib/libcxxrt/Version.map	Sun Feb  9 00:34:21 2014	(r261644)
@@ -111,6 +111,19 @@ CXXABI_1.3 {
         "typeinfo for void";
         "typeinfo for wchar_t const*";
         "typeinfo for wchar_t";
+        # C++11 typeinfo not understood by our linker
+        # std::nullptr_t
+        _ZTIDn;_ZTIPDn;_ZTIPKDn;
+        # char16_t
+        _ZTIDi;_ZTIPDi;_ZTIPKDi;
+        # char32_t
+        _ZTIDs;_ZTIPDs;_ZTIPKDs;
+        # IEEE 754r decimal floating point
+        _ZTIDd;_ZTIPDd;_ZTIPKDd;
+        _ZTIDe;_ZTIPDe;_ZTIPKDe;
+        _ZTIDf;_ZTIPDf;_ZTIPKDf;
+        # IEEE 754r half-precision floating point
+        _ZTIDh;_ZTIPDh;_ZTIPKDh;
 
         "typeinfo for bool*";
         "typeinfo for wchar_t*";
@@ -195,6 +208,19 @@ CXXABI_1.3 {
         "typeinfo name for void*";
         "typeinfo name for unsigned int*";
         "typeinfo name for float*";
+        # C++11 typeinfo not understood by our linker
+        # std::nullptr_t
+        _ZTSDn;_ZTIPDn;_ZTIPKDn;
+        # char16_t
+        _ZTSDi;_ZTIPDi;_ZTIPKDi;
+        # char32_t
+        _ZTSDs;_ZTIPDs;_ZTIPKDs;
+        # IEEE 754r decimal floating point
+        _ZTSDd;_ZTIPDd;_ZTIPKDd;
+        _ZTSDe;_ZTIPDe;_ZTIPKDe;
+        _ZTSDf;_ZTIPDf;_ZTIPKDf;
+        # IEEE 754r half-precision floating point
+        _ZTSDh;_ZTIPDh;_ZTIPKDh;
 
         "typeinfo name for __cxxabiv1::__array_type_info";
         "typeinfo name for __cxxabiv1::__class_type_info";
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 3 dfilter service freebsd_committer 2014-02-09 00:37:26 UTC
Author: dim
Date: Sun Feb  9 00:37:16 2014
New Revision: 261645
URL: http://svnweb.freebsd.org/changeset/base/261645

Log:
  MFC r255093 (by theraven):
  
    Don't use _Unwind_Backtrace() on ARM as it's currently missing from
    our libgcc_s.  andrew@ has patches to add it, so this can be reverted
    and sync'd with upstream later.
  
  MFC r255815 (by theraven):
  
    Import a new libcxxrt.  This fixes some potential crashing in the
    demangler.
  
  MFC r260553 (by theraven):
  
    Add missing C++11 typeinfos to the libcxxrt version script.
  
    PR:		185663

Modified:
  stable/9/contrib/libcxxrt/exception.cc
  stable/9/contrib/libcxxrt/libelftc_dem_gnu3.c
  stable/9/contrib/libcxxrt/typeinfo.cc
  stable/9/contrib/libcxxrt/unwind-itanium.h
  stable/9/lib/libcxxrt/Version.map
Directory Properties:
  stable/9/contrib/libcxxrt/   (props changed)
  stable/9/lib/libcxxrt/   (props changed)

Modified: stable/9/contrib/libcxxrt/exception.cc
==============================================================================
--- stable/9/contrib/libcxxrt/exception.cc	Sun Feb  9 00:34:21 2014	(r261644)
+++ stable/9/contrib/libcxxrt/exception.cc	Sun Feb  9 00:37:16 2014	(r261645)
@@ -715,7 +715,9 @@ static void report_failure(_Unwind_Reaso
 			if (status == 0) { free(demangled); }
 			// Print a back trace if no handler is found.
 			// TODO: Make this optional
+#ifndef __arm__
 			_Unwind_Backtrace(trace, 0);
+#endif
 			break;
 	}
 	std::terminate();

Modified: stable/9/contrib/libcxxrt/libelftc_dem_gnu3.c
==============================================================================
--- stable/9/contrib/libcxxrt/libelftc_dem_gnu3.c	Sun Feb  9 00:34:21 2014	(r261644)
+++ stable/9/contrib/libcxxrt/libelftc_dem_gnu3.c	Sun Feb  9 00:37:16 2014	(r261645)
@@ -405,6 +405,7 @@ static int	cpp_demangle_read_expression_
 		    const char *, size_t, const char *, size_t);
 static int	cpp_demangle_read_function(struct cpp_demangle_data *, int *,
 		    struct vector_type_qualifier *);
+static int	cpp_demangle_local_source_name(struct cpp_demangle_data *ddata);
 static int	cpp_demangle_read_local_name(struct cpp_demangle_data *);
 static int	cpp_demangle_read_name(struct cpp_demangle_data *);
 static int	cpp_demangle_read_nested_name(struct cpp_demangle_data *);
@@ -453,13 +454,22 @@ __cxa_demangle_gnu3(const char *org)
 	struct cpp_demangle_data ddata;
 	ssize_t org_len;
 	unsigned int limit;
-	char *rtn;
+	char *rtn = NULL;
 
 	if (org == NULL)
 		return (NULL);
 
+	org_len = strlen(org);
+	if (org_len > 11 && !strncmp(org, "_GLOBAL__I_", 11)) {
+		if ((rtn = malloc(org_len + 19)) == NULL)
+			return (NULL);
+		snprintf(rtn, org_len + 19,
+		    "global constructors keyed to %s", org + 11);
+		return (rtn);
+	}
+
 	// Try demangling as a type for short encodings
-	if (((org_len = strlen(org)) < 2) || (org[0] != '_' || org[1] != 'Z' )) {
+	if ((org_len < 2) || (org[0] != '_' || org[1] != 'Z' )) {
 		if (!cpp_demangle_data_init(&ddata, org))
 			return (NULL);
 		if (!cpp_demangle_read_type(&ddata, 0))
@@ -467,13 +477,6 @@ __cxa_demangle_gnu3(const char *org)
 		rtn = vector_str_get_flat(&ddata.output, (size_t *) NULL);
 		goto clean;
 	}
-	if (org_len > 11 && !strncmp(org, "_GLOBAL__I_", 11)) {
-		if ((rtn = malloc(org_len + 19)) == NULL)
-			return (NULL);
-		snprintf(rtn, org_len + 19,
-		    "global constructors keyed to %s", org + 11);
-		return (rtn);
-	}
 
 
 	if (!cpp_demangle_data_init(&ddata, org + 2))
@@ -604,13 +607,12 @@ cpp_demangle_push_fp(struct cpp_demangle
 		return (0);
 
 	rtn = 0;
-	if ((len = strlen(f)) > 0 &&
-	    cpp_demangle_push_str(ddata, f, len))
-		rtn = 1;
+	if ((len = strlen(f)) > 0)
+		rtn = cpp_demangle_push_str(ddata, f, len); 
 
 	free(f);
 
-	return (0);
+	return (rtn);
 }
 
 static int
@@ -655,6 +657,7 @@ cpp_demangle_push_subst_v(struct cpp_dem
 		return (0);
 
 	rtn = cpp_demangle_push_subst(ddata, str, str_len);
+
 	free(str);
 
 	return (rtn);
@@ -1868,9 +1871,18 @@ static int
 cpp_demangle_read_sname(struct cpp_demangle_data *ddata)
 {
 	long len;
+	int err;
 
 	if (ddata == NULL || cpp_demangle_read_number(ddata, &len) == 0 ||
-	    len <= 0 || cpp_demangle_push_str(ddata, ddata->cur, len) == 0)
+	    len <= 0)
+		return (0);
+
+ 	if (len == 12 && (memcmp("_GLOBAL__N_1", ddata->cur, 12) == 0))
+		err = cpp_demangle_push_str(ddata, "(anonymous namespace)", 21);
+	else
+		err = cpp_demangle_push_str(ddata, ddata->cur, len);
+	
+	if (err == 0)
 		return (0);
 
 	assert(ddata->output.size > 0);
@@ -2054,7 +2066,7 @@ clean:
 	free(subst_str);
 	vector_str_dest(&v);
 
-	return (1);
+	return (rtn);
 }
 
 static int
@@ -2996,6 +3008,40 @@ cpp_demangle_read_uqname(struct cpp_dema
 	if (ELFTC_ISDIGIT(*ddata->cur) != 0)
 		return (cpp_demangle_read_sname(ddata));
 
+ 
+	/* local source name */ 
+	if (*ddata->cur == 'L') 
+		return (cpp_demangle_local_source_name(ddata)); 
+ 
+	return (1); 
+} 
+ 
+/* 
+ * Read local source name. 
+ * 
+ * References: 
+ *   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31775 
+ *   http://gcc.gnu.org/viewcvs?view=rev&revision=124467 
+ */ 
+static int 
+cpp_demangle_local_source_name(struct cpp_demangle_data *ddata) 
+{ 
+	/* L */ 
+	if (ddata == NULL || *ddata->cur != 'L') 
+		return (0); 
+	++ddata->cur; 
+
+	/* source name */ 
+	if (!cpp_demangle_read_sname(ddata)) 
+		return (0); 
+
+	/* discriminator */ 
+	if (*ddata->cur == '_') { 
+		++ddata->cur; 
+		while (ELFTC_ISDIGIT(*ddata->cur) != 0) 
+			++ddata->cur; 
+	} 
+
 	return (1);
 }
 

Modified: stable/9/contrib/libcxxrt/typeinfo.cc
==============================================================================
--- stable/9/contrib/libcxxrt/typeinfo.cc	Sun Feb  9 00:34:21 2014	(r261644)
+++ stable/9/contrib/libcxxrt/typeinfo.cc	Sun Feb  9 00:37:16 2014	(r261645)
@@ -86,7 +86,18 @@ extern "C" char* __cxa_demangle(const ch
 	if (NULL != demangled)
 	{
 		size_t len = strlen(demangled);
-		buf = (char*)realloc(buf, len+1);
+		if (buf == NULL)
+		{
+			if (n)
+			{
+				*n = len;
+			}
+			return demangled;
+		}
+		if (*n < len+1)
+		{
+			buf = (char*)realloc(buf, len+1);
+		}
 		if (0 != buf)
 		{
 			memcpy(buf, demangled, len);

Modified: stable/9/contrib/libcxxrt/unwind-itanium.h
==============================================================================
--- stable/9/contrib/libcxxrt/unwind-itanium.h	Sun Feb  9 00:34:21 2014	(r261644)
+++ stable/9/contrib/libcxxrt/unwind-itanium.h	Sun Feb  9 00:37:16 2014	(r261645)
@@ -80,7 +80,7 @@ struct _Unwind_Exception
     _Unwind_Exception_Cleanup_Fn exception_cleanup;
     unsigned long private_1;
     unsigned long private_2;
-  };
+  } ;
 
 extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
 extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,

Modified: stable/9/lib/libcxxrt/Version.map
==============================================================================
--- stable/9/lib/libcxxrt/Version.map	Sun Feb  9 00:34:21 2014	(r261644)
+++ stable/9/lib/libcxxrt/Version.map	Sun Feb  9 00:37:16 2014	(r261645)
@@ -111,6 +111,19 @@ CXXABI_1.3 {
         "typeinfo for void";
         "typeinfo for wchar_t const*";
         "typeinfo for wchar_t";
+        # C++11 typeinfo not understood by our linker
+        # std::nullptr_t
+        _ZTIDn;_ZTIPDn;_ZTIPKDn;
+        # char16_t
+        _ZTIDi;_ZTIPDi;_ZTIPKDi;
+        # char32_t
+        _ZTIDs;_ZTIPDs;_ZTIPKDs;
+        # IEEE 754r decimal floating point
+        _ZTIDd;_ZTIPDd;_ZTIPKDd;
+        _ZTIDe;_ZTIPDe;_ZTIPKDe;
+        _ZTIDf;_ZTIPDf;_ZTIPKDf;
+        # IEEE 754r half-precision floating point
+        _ZTIDh;_ZTIPDh;_ZTIPKDh;
 
         "typeinfo for bool*";
         "typeinfo for wchar_t*";
@@ -195,6 +208,19 @@ CXXABI_1.3 {
         "typeinfo name for void*";
         "typeinfo name for unsigned int*";
         "typeinfo name for float*";
+        # C++11 typeinfo not understood by our linker
+        # std::nullptr_t
+        _ZTSDn;_ZTIPDn;_ZTIPKDn;
+        # char16_t
+        _ZTSDi;_ZTIPDi;_ZTIPKDi;
+        # char32_t
+        _ZTSDs;_ZTIPDs;_ZTIPKDs;
+        # IEEE 754r decimal floating point
+        _ZTSDd;_ZTIPDd;_ZTIPKDd;
+        _ZTSDe;_ZTIPDe;_ZTIPKDe;
+        _ZTSDf;_ZTIPDf;_ZTIPKDf;
+        # IEEE 754r half-precision floating point
+        _ZTSDh;_ZTIPDh;_ZTIPKDh;
 
         "typeinfo name for __cxxabiv1::__array_type_info";
         "typeinfo name for __cxxabiv1::__class_type_info";
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2014-02-09 15:35:05 UTC
State Changed
From-To: open->open

appending misfiled PRs. 


Comment 5 Mark Linimon freebsd_committer freebsd_triage 2014-02-09 15:35:05 UTC
Responsible Changed
From-To: freebsd-standards->freebsd-standards
Comment 6 Ed Maste freebsd_committer 2016-06-28 18:14:15 UTC
See also https://reviews.freebsd.org/D7011
Comment 7 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-07-11 09:34:50 UTC
(In reply to Ed Maste from comment #6)
Does it affects libcxxrt of ports too ?
Comment 8 commit-hook freebsd_committer 2018-01-23 22:42:03 UTC
A commit references this bug:

Author: emaste
Date: Tue Jan 23 22:41:14 UTC 2018
New revision: 328305
URL: https://svnweb.freebsd.org/changeset/base/328305

Log:
  libcxxrt: Move mangled symbols out of extern "C++" in Version.map

  r260553 added a number of mangled C++ symbols to Version.map inside of
  an existing `extern "C++"` block.

  ld.bfd 2.17.50 treats `extern "C++"` permissively and will match both
  mangled and demangled symbols against the strings in the version map
  block.  ld.lld interprets `extern "C++"` strictly, and matches only
  demangled symbols.

  I believe lld's behaviour is correct.  Contemporary versions of ld.bfd
  also behave as lld does, so move the mangled symbols out of the
  `extern "C++"` block.

  PR:		225128, 185663
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation

Changes:
  head/lib/libcxxrt/Version.map
Comment 9 Ed Maste freebsd_committer 2018-01-23 22:44:37 UTC
(In reply to Mahdi Mokhtari from comment #7)
> Does it affects libcxxrt of ports too ?

Can you clarify this question, I don't follow.
Comment 10 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-01-24 10:57:05 UTC
Hmm, I don't think the question I have asked is valid anymore :)
As a brief, on that time we have had a port for libcxxrt on the ports (because the base's was kinda outdated) but the port's libcxxrt doesn't exist anymore (because base's is update enough).
So in that time I have asked does the bug also affect the port's libcxxrt or not (because I was maintainer of the port by the time).
Comment 11 commit-hook freebsd_committer 2018-01-30 01:13:57 UTC
A commit references this bug:

Author: emaste
Date: Tue Jan 30 01:13:06 UTC 2018
New revision: 328583
URL: https://svnweb.freebsd.org/changeset/base/328583

Log:
  MFC r328305: libcxxrt: Move mangled symbols out of extern "C++" in Version.map

  r260553 added a number of mangled C++ symbols to Version.map inside of
  an existing `extern "C++"` block.

  ld.bfd 2.17.50 treats `extern "C++"` permissively and will match both
  mangled and demangled symbols against the strings in the version map
  block.  ld.lld interprets `extern "C++"` strictly, and matches only
  demangled symbols.

  I believe lld's behaviour is correct.  Contemporary versions of ld.bfd
  also behave as lld does, so move the mangled symbols out of the
  `extern "C++"` block.

  PR:		225128, 185663
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  stable/11/
  stable/11/lib/libcxxrt/Version.map