]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: avoid <memory> poisoning on musl [PR106102]
authorSergei Trofimovich <siarheit@google.com>
Mon, 27 Jun 2022 12:27:24 +0000 (13:27 +0100)
committerSergei Trofimovich <siarheit@google.com>
Sat, 2 Jul 2022 15:21:24 +0000 (16:21 +0100)
On musl <pthread.h> uses calloc() (via <sched.h>). <memory> includes
it indirectly and exposes use of poisoned calloc() when module code
is built:

    /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc
        In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35,
                 ....
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77,
                 from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23,
                 from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32:
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"
       84 | void *calloc(size_t, size_t);
          |       ^
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc"
      124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
          |                                    ^

gcc/cp/

PR c++/106102
* mapper-client.cc: Include <memory> via "system.h".
* mapper-resolver.cc: Ditto.
* module.cc: Ditto.

libcc1/

PR c++/106102
* libcc1plugin.cc: Include <memory> via "system.h".
* libcp1plugin.cc: Ditto.

(cherry picked from commit 3b21c21f3f5726823e19728fdd1571a14aae0fb3)

gcc/cp/mapper-client.cc
gcc/cp/mapper-resolver.cc
gcc/cp/module.cc
libcc1/libcc1plugin.cc
libcc1/libcp1plugin.cc

index 8603a886a099d06cc4a08202d3a56395d1aadedf..fe9544b5ba43e02d47e2685fd54243abd0ed7161 100644 (file)
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #define INCLUDE_STRING
 #define INCLUDE_VECTOR
 #define INCLUDE_MAP
+#define INCLUDE_MEMORY
 #include "system.h"
 
 #include "line-map.h"
index e3d29fb5ada162ee2830745fcc27649708707fb4..e70d1b4ae2cae80c06c79238f628f045704c588e 100644 (file)
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #define INCLUDE_VECTOR
 #define INCLUDE_ALGORITHM
 #define INCLUDE_MAP
+#define INCLUDE_MEMORY
 #include "system.h"
 
 // We don't want or need to be aware of networking
index cebf9c35c1dea3de9ae17833ebf59e6f612e8af3..5c5d02bb523867846d36c68f56e402ffc1e660a3 100644 (file)
@@ -202,6 +202,7 @@ Classes used:
 
 #define _DEFAULT_SOURCE 1 /* To get TZ field of struct tm, if available.  */
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #define INCLUDE_VECTOR
 #include "system.h"
index 12ab5a57c8ddcf02468b28381a7cea4e1191b869..bdd0bdabe77f8c8e7d45c94eec68b1b4f77db09e 100644 (file)
@@ -31,6 +31,7 @@
 #undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION
 
+#define INCLUDE_MEMORY
 #include "gcc-plugin.h"
 #include "system.h"
 #include "coretypes.h"
index 83dab7f58b11f9e007dd7abd4dd8272027ccfcd9..e2d5039a0a1f3b2a18db7ac7fca696dab52a4fcc 100644 (file)
@@ -32,6 +32,7 @@
 #undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION
 
+#define INCLUDE_MEMORY
 #include "gcc-plugin.h"
 #include "system.h"
 #include "coretypes.h"