fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.84k stars 2.42k forks source link

Ability to force use of fallback_file #3992

Closed Wraiyth closed 2 weeks ago

Wraiyth commented 1 month ago

We have an issue where we are getting a crash in template <typename U> void append(const U* begin, const U* end) L919 memcpy(ptr_ + size_, begin, count * sizeof(T)); due to ptr_ being uninitialized. We have tracked this down to the underlying file buffer not being correctly initialized on this platform (a game console).

This particular platform does not have the flockfile, funlockfile, getc_unlocked and putc_unlocked posix methods. We've stubbed these out and forwarded them onto the platform methods, but still experiencing the same issue.

Ideally we would like to just force fmt to use fallback_file on this platform instead of apple_file (which is what is being detected and used). Is there a way for us to do this in the library as it stands? We have added a FMT_FORCE_FALLBACK define around the templating of get_file to just force it in our own fork at this stage.

For context, this issue was not present in 9.x when we were using it, and seems related to the buffering changes introduced in https://github.com/fmtlib/fmt/commit/6b68dff90185efd6dd618fd315b5325b9fd0df16 this commit.

vitaut commented 1 month ago

Is there a way for us to do this in the library as it stands?

No but a PR to control it via a macro would be welcome.

Wraiyth commented 3 weeks ago

Is there a way for us to do this in the library as it stands?

No but a PR to control it via a macro would be welcome.

Absolutely! I just wanted to confirm I wasn't missing something else. I've opened PR https://github.com/fmtlib/fmt/pull/4009 with this define.