-
-
Notifications
You must be signed in to change notification settings - Fork 7k
curlx: move fopen and multibyte to curlx_malloc #19748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
CI is so good, you can see what you break! |
|
I guess this would break debug builds because these calls are |
|
So why do we need to fopen() magic in the memdebug code? It's just debug code, we can keep it simple can we not? |
It's saving files to disk, and saving files to disk involves dealing with |
This is debug code - we control the entire thing. We don't need to accept unicode and weird stuff here. |
|
Then is creates and exception, which needs to be kept in mind and dealt all the time. What would be the goal of using the debug/curl allocators in these low-level functions? |
|
I think my main point is that the malloc() replacement feels more important since they are used in production code, while the memdebug code is primarily for us to debug curl with and we use those in more controlled environments and it feels easy enough to apply a few restrictions there, if the benefit is that we can do the mallocs correctly. |
That was a bug. We offer users the ability to replace all libcurl mallocs to instead use their allocation functions. |
This just reverses the exception. Instead of accepting malloc() in production code this has to accept fopen and freopen in debug code. |
|
@vszakats are these windows CI failures due to this change? They look odd! |
|
They seem to be crashing on Forgot to say thet memdebug functions also wrap fopen/open functions These allocators are fine. They could probably be updated to use |
That would not help though. I want us to A) honor the curl_global_init_mem() function as well as possible. The user then provides their set of allocation functions to replace the ones libcurl uses. We therefore need to use the correct set to have this work. B) for debug builds, I want the memdebug system to trace all the memory calls we do in curl + libcurl, which then also requires us to use the correct set |
|
I'd argue these goals aren't worth the mess it may need to support For fopen, these Windows-specific allocations are self-contained, For the two multibyte ones, and their unicodefree pair, memdebug But, I also have no idea how to achieve these goals without making fopen/open can be dumbed down for debug-enabled builds, which For the unicode functions: Unicode barely works in curl, so perhaps A duplicate copy of these functions could be kept that's exclusively Finally, just to make it clear because I feel this is now suddenly on And as always: it's more than likely I'm missing something. |
I don't think it is on you nor "your problem". I think it is just like always. Iteratively taking steps forward. You took this a big step forward which then enabled me to spot and realize this particular detail that I would like to fix. |
Phew, thanks for clarifying! It's good it's easier to oversee what's IMO it'd be worth considering to declare defeat for the "WIDE" But! According to comments, For non-Windows multibye, I'm trying to map them to the curlx |
|
|
Let's see what fallout this makes
7c4f5b9 to
2613bd9
Compare
In idn.c it might have that limit, but the function is also used for filenames in fopen.c and I figure they can be (much) larger than 255. |
Sorry, I meant to say to replace the curlx calls in idn.c with direct MultiByte* This would reduce raw memallocs, a bit. It'd also remove the last uses of the |
Ah right. Yeah that would simplify things a little! |
Eliminate a heap buffer in both `win32_idn_to_ascii()` and `win32_ascii_to_idn()`, by replacing it with stack buffer. The maximum size is fixed in these cases, and small enough to fit there. Also reuse length returned by the UTF-8 to wchar conversion, allowing to drop `wcslen()` call in both functions, and allowing to call the wchar to UTF-8 conversion API `WideCharToMultiByte()` with the known length, saving length calculations within that API too. Ref: #19748 (comment) Closes #19798
|
Made #19845 to fix this. Reduces system allocator use to Windows |
Let's see what fallout this makes