Hello,

In recent commit "crt: Avoid best-fit mapping when constructing argv for main()"
https://sourceforge.net/p/mingw-w64/mingw-w64/ci/0d42217123d3aec0341b79f6d959c76e09648a1e/
was done big change in how all compiled applications will handle access
to argc and argv[].

I consider this change more harmful for more reasons.

It breaks usage of global variables __argc and __argv[].
It breaks support for global variable _dowildcard.
It breaks gcc's -mcrt=crtdll compile option.

It is not so uncommon to use __argc and __argv[] for processing cmdline
arguments. For example even mingw-w64 implementation of getopt() used
__argv[] until few months ago this was changed.

Also the error message about unsupported command line characters are
redirected to nul when compiling with gcc's -mwindows option. Which
makes all GUI applications less user friendly as they will silently fail
without any notice.

And it also affects how environment variables works. With this change,
wide variant of environment variables are initialized even when
compiling in non-unicode mode. It is because crt code calls both
__getmainargs() and __getmainargs() function. In CRT just exactly one
function has to be called as this is how the API was designed. This can
be confusing for libraries which access global variables (either
directly or via helper functions), for example env variables too.

Questionable is also how it affected support for POSIX "environ" global
variable (aliased to _environ).

Btw, I think that this change also breaks all mingw-w64 applications for
running on older Windows versions as IIRC flag WC_NO_BEST_FIT_CHARS was
not available in older Windows versions. And recently people still
report small bugs to older Windows versions. For example I was fixing
small compile issue related to Windows NT because it was reported as a
bug (regression to one my change in mingw-w64). So mingw-w64
applications are still used on older Windows versions.

In my opinion, this change should be revisited and ideally reverted and
implemented again with more safe and less drastic way.

Change has really big potential to break lot of applications which are
working fine. And because this new behavior cannot be turned off by any
compile option there is no workaround for those applications.

Instead of applying it globally for all applications, it could be
backward compatible. For example enabled by some global variable, like
it was done for all other new msvcrt backward incompatible features.



Also followup change "crt/crtexe: Remove `duplicate_ppstrings()`"
https://sourceforge.net/p/mingw-w64/mailman/message/58835361/
makes inconsistency between main and wmain with what happens with global
variable __wargv[] when modifying wmain's wargv[] argument.

I think that main and wmain functions should be consistent how they
handle theirs arguments and how it affects global variables __argv and
__wargv. Either both main and wmain should alias its own arguments with
global variables or none of them.

And because of how getopt worked, I would rather suggest to not alias
wmain arguments to global variables.

Note that above change does not fix following bug
https://sourceforge.net/p/mingw-w64/bugs/809/
because argv is still leaking memory after "Avoid best-fit mapping"
change.


I can look at those changes and try to prepare some less drastic change
which could address issues which I have described. But for now I have
too many mingw-w64 changes which are pending / waiting for review and I
rather not start something new as it makes me hard to rebase and track
lot of patches...

Pali


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to