On Jul 31 14:05, Jeremy Drake via Cygwin-patches wrote: > On Thu, 31 Jul 2025, Corinna Vinschen wrote: > > libstdc++-6.dll already uses the newer new/delete calls, right? Looks > > like this works with old DLLs except overloading the operators will have > > no result because these operators are unused in libstdc++-6.dll? > > > > I do hope I got that right... > > I'm not sure it uses them, but if it does it would not work with > overloading the operators because they are not wrapped yet.
Yeah, but then, even today. > > We know that old DLLs don't write a value into __cygwin_user_data.api_major > > and __cygwin_user_data.api_minor. > > > > But what if the new Cygwin DLL does just that? > > > > Assuming dll_crt0_0 (definitely called prior to _cygwin_crt0_common) > > writes the current DLL CYGWIN_VERSION_API_MAJOR and > > CYGWIN_VERSION_API_MINOR values into __cygwin_user_data.api_major/minor. > > > > Then _cygwin_crt0_common could check this before api_major/minor are > > overwritten with the app version, and then use this info when > > performing the CONDITIONALLY_OVERRIDEs. > > > + if (newu) > > + new_dll_with_additional_operators = newu->api_major != 0 > > + || newu->api_minor != 0; > > + > > I'm considering 3 cases for _cygwin_crt0_common here, order in which they > happen > 1) running from a linked dll's startup (ie, libstdc++-6.dll) > newu would contain values initialized from cygwin dll's startup, would > write its api versions to static struct per_process in > cygwin_attach_dll, OK > > 2) running from exe's startup > newu would still contain values initialized from cygwin dll's startup, > would write it's api versions to newu due to assignment of u = newu. > OK for now > > 3) running from dynamically loaded DLL's startup > newu would contain values from exe's startup, not zero, so would always > write the new pointers to cxx_malloc, memory corruption. Ah, ok, but then again, in this case a check against the actual version instead of checking just against != 0 should do it, shouldn't it? E.g. new_dll_with_additional_operators = newu->api_major != 0 || newu->api_minor >= 359; That should be rewritten to a version check macro eventually, but it would disable wrapping the new functions depending on the executable being too old, even if the just loaded DLL is new enough. But that should be ok. Better than crashing methinks. Corinna