On Wed, 30 Jul 2025, Corinna Vinschen wrote:

> On Jul 25 16:10, Jeremy Drake via Cygwin-patches wrote:
> > A sized delete (with a std::size_t parameter) was added in C++14 (but
> > doesn't combine with nothrow_t)
> >
> > An aligned new/delete (with a std::align_val_t parameter) was added in
> > C++17, and combinations with the sized delete and nothrow_t variants.
> >
> > Signed-off-by: Jeremy Drake <cyg...@jdrake.com>
> > ---
> > I added #pragma GCC diagnostic ignored "-Wc++17-compat" preemptively to
> > cxx.cc to match what was done with c++14-compat with the one sized delete
> > that was already present (presumably because it broke things when GCC
> > started to emit that instead of the non-sized delete).
> >
> > The default new implementation uses calloc, so I'm not sure if it's
> > expected that the aligned new call memset to zero the returned memory.
> > It'd be easy enough to add if necessary.
> >
> > GCC will need to be updated circa
> > https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/i386/cygwin-w64.h;h=160a290a03d00f6408252f5d8751fea7cd44e1be;hb=HEAD#l27
> > but only after this change is stable because it will cause linker errors
> > if the new __wrap symbols are not exported.
> >
> > Does there need to be a version bump somewhere to make sure a module
> > linked against a new libcygwin.a doesn't run against an old cygwin1.dll,
> > resulting in _cygwin_crt0_common.cc writing too much data to
> > default_cygwin_cxx_malloc?
> >
> >  winsup/cygwin/cxx.cc                      | 120 +++++++++++++++++++++-
> >  winsup/cygwin/cygwin.din                  |  12 +++
> >  winsup/cygwin/lib/_cygwin_crt0_common.cc  |  59 +++++++++++
> >  winsup/cygwin/libstdcxx_wrapper.cc        |  99 ++++++++++++++++++
> >  winsup/cygwin/local_includes/cygwin-cxx.h |  14 +++
> >  5 files changed, 299 insertions(+), 5 deletions(-)
>
> LGTM.  Please push (to main only, at least for now)

Done.  I was figuring this was a 3.7-only change.

I was thinking, in _cygwin_crt0_common.cc where the __cygwin_cxx_malloc
struct is handled, perhaps it could "CONDITIONALLY_OVERRIDE" into the
newu->cxx_malloc struct (from the dll) directly instead of merging into
the local __cygwin_cxx_malloc struct and copying the entire struct over
the dll struct.  This might allow a binary built against a newer
libcygwin.a to not crash (or corrupt memory) if run against an older dll,
as long as the newer C++ new/delete operators were not defined.  The
sticking point would be libstdc++-6.dll once it is rebuilt with the
additional --wrap arguments in GCC, because it would define all the
operators and thus be incompatbile with older dll versions.

Reply via email to