On Tuesday 08 April 2025 19:23:37 Lasse Collin wrote:
> On 2025-04-06 Pali Rohár wrote:
> > On Saturday 29 March 2025 18:56:56 Lasse Collin wrote:
> > > On 2025-03-29 Pali Rohár wrote:  
> > > > Problem is that you cannot define _USE_32BIT_TIME_T on UCRT
> > > > builds. There are header ifdef checks that combination of
> > > > _USE_32BIT_TIME_T and _UCRT throw preprocessor #error. But UCRT
> > > > has _stat32 and also _stat32i64 functions. So this would not
> > > > work.  
> > > 
> > > I might not fully understand how much this matters.
> > > 
> > >   - Currently one doesn't need to build any stat*.c files for UCRT.
> > >     The .def file redirects statxxx to _statxxx.
> > > 
> > >   - The way I see it, having the fstat/stat/wstat symbols matters
> > >     mostly for Autoconf checks. Normal applications rely on
> > >     <sys/stat.h>, and then the default symbol doesn't matter.
> > > 
> > > <ftw.h> uses "struct stat", not any underscore version. When apps
> > > cannot get 32-bit time_t variants of "struct stat" from
> > > <sys/stat.h>,  
> > 
> > Application can get it when building in msvcrt mode. Application
> > cannot get it when building in UCRT mode. Both clang and gcc allows
> > to chose build mode at application build time (not just at mingw-w64
> > build time). gcc has -mcrtdll= switch and clang has -lmsvc* switches.
> 
> This is the thing I had missed. Thanks!
> 
> > > With MSVCRT, stat64 comes from stat64.c, and if that is built with
> > > some -fsanitize, then the type mismatch between <sys/stat.h> and
> > > stat64.c would be detected. The problem would be stat() when it's
> > > redirected to stat64() because stat64.c expects "struct stat64 *"
> > > while stat() uses "struct stat *".  
> > 
> > When I'm looking at the ftw() implementation, it has already exactly
> > same problem. It is taking an fcb function parameter of type:
> > 
> >    int (*fcb) (const char *, const STRUCT_STAT *, int)
> > 
> > But it calling it as a different signature:
> > 
> >    (*ctx->fcb) (buf, st, flag, ftw);
> > 
> > It contains additional argument.
> > 
> > So I think that the ftw code to work with clang already needs to
> > disable CFI checks.
> 
> Yes. I commented this shortly on 2025-03-29. The callback part is easy
> to fix, for example, by having two function pointers in the ctx_t
> structure. But since it's not causing real-world problems (other than
> the -fsanitize usage), this doesn't need to be modified now.
> 
> > Hence I would propose to fix the broken stat functions to work without
> > CFI and later if somebody comes with a suitable solution we can fix it
> > also for CFI-enabled compilers.
> 
> I agree. The patches are a major improvement already. :-)
> 
> If you like, feel free to include my stat patches 1-8 from 2025-03-22
> when you submit yours. Alternatively, I will send mine separately after
> yours have been merged. Do whichever you prefer.
> 
> Thanks!
> 
> -- 
> Lasse Collin

I will send my patches. And then we can continue with other
improvements. Lets have at least something finished and merged.


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

Reply via email to