public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kito Cheng <kito.cheng@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Sam James <sam@gentoo.org>,
	gcc-patches@gcc.gnu.org,  Palmer Dabbelt <palmer@dabbelt.com>,
	Andrew Waterman <andrew@sifive.com>,
	 Jim Wilson <jim.wilson.gcc@gmail.com>,
	Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Subject: Re: [PATCH v4 1/2] RISC-V: Avoid calloc() poisoning on musl
Date: Tue, 14 Mar 2023 21:48:18 +0800	[thread overview]
Message-ID: <CA+yXCZDp7Mut+A09a3HOJQJ75rDWEhPpVMQhyNoty-1chbNBrA@mail.gmail.com> (raw)
In-Reply-To: <CA+yXCZCaT1yM_V-hyx8y+bg4ahLpA0CsSyQ4PPKBm9UY81RWOw@mail.gmail.com>

committed to trunk, thanks :)

On Tue, Mar 14, 2023 at 9:44 PM Kito Cheng <kito.cheng@gmail.com> wrote:
>
> RISC-V part is ok, and I assume you didn't have write access so I'm
> gonna push that since the system.h change also got approved :)
>
> On Tue, Mar 14, 2023 at 5:07 PM Richard Biener via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > On Tue, Mar 14, 2023 at 1:24 AM Sam James via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> > >
> > > This fixes errors like:
> > > ```
> > > In file included from /usr/include/pthread.h:30,
> > >                  from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr-default.h:35,
> > >                  from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/riscv64-gentoo-linux-musl/bits/gthr.h:148,
> > >                  from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ext/atomicity.h:35,
> > >                  from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/bits/ios_base.h:39,
> > >                  from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/ios:42,
> > >                  from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/istream:38,
> > >                  from /usr/lib/gcc/riscv64-gentoo-linux-musl/12/include/g++-v12/sstream:38,
> > >                  from /var/tmp/portage/sys-devel/gcc-13.0.1_pre20230305/work/gcc-13-20230305/gcc/config/riscv/genrvv-type-indexer.cc:22:
> > > /usr/include/sched.h:84:7: error: attempt to use poisoned "calloc"
> > >    84 | void *calloc(size_t, size_t);
> > >       |       ^
> > > /usr/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)))
> > >       |                                    ^
> > > make[3]: *** [Makefile:2855: build/genrvv-type-indexer.o] Error 1
> > > ```
> > >
> > > See also 3b21c21f3f5726823e19728fdd1571a14aae0fb3 and 49d508065bdd36fb1a9b6aad9666b1edb5e06474,
> > > which was fixed in PR106102.
> >
> > The system.h change is OK
> >
> > > gcc/ChangeLog:
> > >         * config/riscv/genrvv-type-indexer.cc: Avoid calloc() poisoning on musl by
> > >         including <sstream> earlier.
> > >         * system.h: Add INCLUDE_SSTREAM.
> > >
> > > Signed-off-by: Sam James <sam@gentoo.org>
> > > ---
> > >  gcc/config/riscv/genrvv-type-indexer.cc | 2 +-
> > >  gcc/system.h                            | 4 ++++
> > >  2 files changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/gcc/config/riscv/genrvv-type-indexer.cc b/gcc/config/riscv/genrvv-type-indexer.cc
> > > index 0ef1d766002..e677b55290c 100644
> > > --- a/gcc/config/riscv/genrvv-type-indexer.cc
> > > +++ b/gcc/config/riscv/genrvv-type-indexer.cc
> > > @@ -14,12 +14,12 @@ along with GCC; see the file COPYING3.  If not see
> > >  <http://www.gnu.org/licenses/>.  */
> > >
> > >  #include "bconfig.h"
> > > +#define INCLUDE_SSTREAM
> > >  #include "system.h"
> > >  #include "errors.h"
> > >
> > >  #include "coretypes.h"
> > >
> > > -#include <sstream>
> > >  #include <assert.h>
> > >  #include <math.h>
> > >
> > > diff --git a/gcc/system.h b/gcc/system.h
> > > index 64cd5a49258..cf45db3f97e 100644
> > > --- a/gcc/system.h
> > > +++ b/gcc/system.h
> > > @@ -751,6 +751,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list);
> > >  # include <mutex>
> > >  #endif
> > >
> > > +#ifdef INCLUDE_SSTREAM
> > > +# include <sstream>
> > > +#endif
> > > +
> > >  #ifdef INCLUDE_MALLOC_H
> > >  #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
> > >  #include <malloc.h>
> > > --
> > > 2.40.0
> > >

  reply	other threads:[~2023-03-14 13:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14  0:23 Sam James
2023-03-14  0:23 ` [PATCH v4 2/2] gcc: Drop obsolete INCLUDE_PTHREAD_H Sam James
2023-03-14  0:27   ` juzhe.zhong
2023-03-14 13:45     ` Kito Cheng
2023-03-14 14:44       ` Jeff Law
2023-03-31 18:44       ` [PATCH v4 2/2] gcc: Drop obsolete INCLUDE_PTHREAD_H (ping) Sam James
2023-04-02 19:54         ` Jeff Law
2023-04-02 20:06           ` Andrew Pinski
2023-04-02 20:07             ` Jeff Law
2023-04-02 20:13               ` Andrew Pinski
2023-04-02 20:16               ` Sam James
2023-03-14  9:06 ` [PATCH v4 1/2] RISC-V: Avoid calloc() poisoning on musl Richard Biener
2023-03-14 13:44   ` Kito Cheng
2023-03-14 13:48     ` Kito Cheng [this message]
2023-03-14 22:06       ` Sam James
2023-03-14 21:39     ` Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+yXCZDp7Mut+A09a3HOJQJ75rDWEhPpVMQhyNoty-1chbNBrA@mail.gmail.com \
    --to=kito.cheng@gmail.com \
    --cc=andrew@sifive.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jim.wilson.gcc@gmail.com \
    --cc=juzhe.zhong@rivai.ai \
    --cc=palmer@dabbelt.com \
    --cc=richard.guenther@gmail.com \
    --cc=sam@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).