Bug 1717448 - Don't use std::generic_category and other error reporting facilities, ignore IO errors. r=glandium
Otherwise we get: TEST-UNEXPECTED-FAIL | check_binary_compat | SmokeDMD | We do not want these libstdc++ symbol versions to be used: INFO - _ZNSt3_V216generic_categoryEv (GLIBCXX_3.4.21) And also we'd rather not crash on IO errors, that are probably not going to be used in production anyways. Differential Revision: https://phabricator.services.mozilla.com/D218066
This commit is contained in:
176
third_party/fmt/comment-format-system-error.patch
vendored
Normal file
176
third_party/fmt/comment-format-system-error.patch
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h
|
||||
--- a/include/fmt/format-inl.h
|
||||
+++ b/include/fmt/format-inl.h
|
||||
@@ -69,19 +69,20 @@ FMT_FUNC void do_report_error(format_fun
|
||||
func(full_message, error_code, message);
|
||||
// Don't use fwrite_all because the latter may throw.
|
||||
if (std::fwrite(full_message.data(), full_message.size(), 1, stderr) > 0)
|
||||
std::fputc('\n', stderr);
|
||||
}
|
||||
|
||||
// A wrapper around fwrite that throws on error.
|
||||
inline void fwrite_all(const void* ptr, size_t count, FILE* stream) {
|
||||
- size_t written = std::fwrite(ptr, 1, count, stream);
|
||||
- if (written < count)
|
||||
- FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
||||
+ std::fwrite(ptr, 1, count, stream);
|
||||
+ // size_t written = std::fwrite(ptr, 1, count, stream);
|
||||
+ // if (written < count)
|
||||
+ // FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
||||
}
|
||||
|
||||
#if FMT_USE_LOCALE
|
||||
using std::locale;
|
||||
using std::numpunct;
|
||||
using std::use_facet;
|
||||
|
||||
template <typename Locale, enable_if_t<(sizeof(Locale::collate) != 0), int>>
|
||||
@@ -153,21 +154,21 @@ template <typename Locale> format_facet<
|
||||
template <>
|
||||
FMT_API FMT_FUNC auto format_facet<std::locale>::do_put(
|
||||
appender out, loc_value val, const format_specs& specs) const -> bool {
|
||||
return val.visit(
|
||||
detail::loc_writer<>{out, specs, separator_, grouping_, decimal_point_});
|
||||
}
|
||||
#endif
|
||||
|
||||
-FMT_FUNC auto vsystem_error(int error_code, string_view fmt, format_args args)
|
||||
- -> std::system_error {
|
||||
- auto ec = std::error_code(error_code, std::generic_category());
|
||||
- return std::system_error(ec, vformat(fmt, args));
|
||||
-}
|
||||
+// FMT_FUNC auto vsystem_error(int error_code, string_view fmt, format_args args)
|
||||
+// -> std::system_error {
|
||||
+// auto ec = std::error_code(error_code, std::generic_category());
|
||||
+// return std::system_error(ec, vformat(fmt, args));
|
||||
+// }
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename F>
|
||||
inline auto operator==(basic_fp<F> x, basic_fp<F> y) -> bool {
|
||||
return x.f == y.f && x.e == y.e;
|
||||
}
|
||||
|
||||
@@ -1418,22 +1419,22 @@ FMT_FUNC detail::utf8_to_utf16::utf8_to_
|
||||
}
|
||||
return true;
|
||||
});
|
||||
buffer_.push_back(0);
|
||||
}
|
||||
|
||||
FMT_FUNC void format_system_error(detail::buffer<char>& out, int error_code,
|
||||
const char* message) noexcept {
|
||||
- FMT_TRY {
|
||||
- auto ec = std::error_code(error_code, std::generic_category());
|
||||
- detail::write(appender(out), std::system_error(ec, message).what());
|
||||
- return;
|
||||
- }
|
||||
- FMT_CATCH(...) {}
|
||||
+ // FMT_TRY {
|
||||
+ // auto ec = std::error_code(error_code, std::generic_category());
|
||||
+ // detail::write(appender(out), std::system_error(ec, message).what());
|
||||
+ // return;
|
||||
+ // }
|
||||
+ // FMT_CATCH(...) {}
|
||||
format_error_code(out, error_code, message);
|
||||
}
|
||||
|
||||
FMT_FUNC void report_system_error(int error_code,
|
||||
const char* message) noexcept {
|
||||
do_report_error(format_system_error, error_code, message);
|
||||
}
|
||||
|
||||
diff --git a/include/fmt/format.h b/include/fmt/format.h
|
||||
--- a/include/fmt/format.h
|
||||
+++ b/include/fmt/format.h
|
||||
@@ -4189,55 +4189,55 @@ class format_int {
|
||||
*
|
||||
* **Example**:
|
||||
*
|
||||
* // A compile-time error because 'd' is an invalid specifier for strings.
|
||||
* std::string s = fmt::format(FMT_STRING("{:d}"), "foo");
|
||||
*/
|
||||
#define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string)
|
||||
|
||||
-FMT_API auto vsystem_error(int error_code, string_view fmt, format_args args)
|
||||
- -> std::system_error;
|
||||
+// FMT_API auto vsystem_error(int error_code, string_view fmt, format_args args)
|
||||
+// -> std::system_error;
|
||||
|
||||
/**
|
||||
* Constructs `std::system_error` with a message formatted with
|
||||
* `fmt::format(fmt, args...)`.
|
||||
* `error_code` is a system error code as given by `errno`.
|
||||
*
|
||||
* **Example**:
|
||||
*
|
||||
* // This throws std::system_error with the description
|
||||
* // cannot open file 'madeup': No such file or directory
|
||||
* // or similar (system message may vary).
|
||||
* const char* filename = "madeup";
|
||||
* FILE* file = fopen(filename, "r");
|
||||
* if (!file)
|
||||
* throw fmt::system_error(errno, "cannot open file '{}'", filename);
|
||||
*/
|
||||
-template <typename... T>
|
||||
-auto system_error(int error_code, format_string<T...> fmt, T&&... args)
|
||||
- -> std::system_error {
|
||||
- return vsystem_error(error_code, fmt.str, vargs<T...>{{args...}});
|
||||
-}
|
||||
+// template <typename... T>
|
||||
+// auto system_error(int error_code, format_string<T...> fmt, T&&... args)
|
||||
+// -> std::system_error {
|
||||
+// return vsystem_error(error_code, fmt.str, vargs<T...>{{args...}});
|
||||
+// }
|
||||
|
||||
/**
|
||||
* Formats an error message for an error returned by an operating system or a
|
||||
* language runtime, for example a file opening error, and writes it to `out`.
|
||||
* The format is the same as the one used by `std::system_error(ec, message)`
|
||||
* where `ec` is `std::error_code(error_code, std::generic_category())`.
|
||||
* It is implementation-defined but normally looks like:
|
||||
*
|
||||
* <message>: <system-message>
|
||||
*
|
||||
* where `<message>` is the passed message and `<system-message>` is the system
|
||||
* message corresponding to the error code.
|
||||
* `error_code` is a system error code as given by `errno`.
|
||||
*/
|
||||
-FMT_API void format_system_error(detail::buffer<char>& out, int error_code,
|
||||
- const char* message) noexcept;
|
||||
+// FMT_API void format_system_error(detail::buffer<char>& out, int error_code,
|
||||
+// const char* message) noexcept;
|
||||
|
||||
// Reports a system error without throwing an exception.
|
||||
// Can be used to report errors from destructors.
|
||||
FMT_API void report_system_error(int error_code, const char* message) noexcept;
|
||||
|
||||
inline auto vformat(detail::locale_ref loc, string_view fmt, format_args args)
|
||||
-> std::string {
|
||||
auto buf = memory_buffer();
|
||||
diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h
|
||||
--- a/include/fmt/xchar.h
|
||||
+++ b/include/fmt/xchar.h
|
||||
@@ -286,18 +286,19 @@ inline auto formatted_size(const S& fmt,
|
||||
fmt::make_format_args<buffered_context<Char>>(args...));
|
||||
return buf.count();
|
||||
}
|
||||
|
||||
inline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {
|
||||
auto buf = wmemory_buffer();
|
||||
detail::vformat_to(buf, fmt, args);
|
||||
buf.push_back(L'\0');
|
||||
- if (std::fputws(buf.data(), f) == -1)
|
||||
- FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
||||
+ std::fputws(buf.data(), f);
|
||||
+ // if (std::fputws(buf.data(), f) == -1)
|
||||
+ // FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
||||
}
|
||||
|
||||
inline void vprint(wstring_view fmt, wformat_args args) {
|
||||
vprint(stdout, fmt, args);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void print(std::FILE* f, wformat_string<T...> fmt, T&&... args) {
|
||||
29
third_party/fmt/include/fmt/format-inl.h
vendored
29
third_party/fmt/include/fmt/format-inl.h
vendored
@@ -74,9 +74,10 @@ FMT_FUNC void do_report_error(format_func func, int error_code,
|
||||
|
||||
// A wrapper around fwrite that throws on error.
|
||||
inline void fwrite_all(const void* ptr, size_t count, FILE* stream) {
|
||||
size_t written = std::fwrite(ptr, 1, count, stream);
|
||||
if (written < count)
|
||||
FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
||||
std::fwrite(ptr, 1, count, stream);
|
||||
// size_t written = std::fwrite(ptr, 1, count, stream);
|
||||
// if (written < count)
|
||||
// FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
||||
}
|
||||
|
||||
#if FMT_USE_LOCALE
|
||||
@@ -158,11 +159,11 @@ FMT_API FMT_FUNC auto format_facet<std::locale>::do_put(
|
||||
}
|
||||
#endif
|
||||
|
||||
FMT_FUNC auto vsystem_error(int error_code, string_view fmt, format_args args)
|
||||
-> std::system_error {
|
||||
auto ec = std::error_code(error_code, std::generic_category());
|
||||
return std::system_error(ec, vformat(fmt, args));
|
||||
}
|
||||
// FMT_FUNC auto vsystem_error(int error_code, string_view fmt, format_args args)
|
||||
// -> std::system_error {
|
||||
// auto ec = std::error_code(error_code, std::generic_category());
|
||||
// return std::system_error(ec, vformat(fmt, args));
|
||||
// }
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -1423,12 +1424,12 @@ FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) {
|
||||
|
||||
FMT_FUNC void format_system_error(detail::buffer<char>& out, int error_code,
|
||||
const char* message) noexcept {
|
||||
FMT_TRY {
|
||||
auto ec = std::error_code(error_code, std::generic_category());
|
||||
detail::write(appender(out), std::system_error(ec, message).what());
|
||||
return;
|
||||
}
|
||||
FMT_CATCH(...) {}
|
||||
// FMT_TRY {
|
||||
// auto ec = std::error_code(error_code, std::generic_category());
|
||||
// detail::write(appender(out), std::system_error(ec, message).what());
|
||||
// return;
|
||||
// }
|
||||
// FMT_CATCH(...) {}
|
||||
format_error_code(out, error_code, message);
|
||||
}
|
||||
|
||||
|
||||
18
third_party/fmt/include/fmt/format.h
vendored
18
third_party/fmt/include/fmt/format.h
vendored
@@ -4194,8 +4194,8 @@ class format_int {
|
||||
*/
|
||||
#define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string)
|
||||
|
||||
FMT_API auto vsystem_error(int error_code, string_view fmt, format_args args)
|
||||
-> std::system_error;
|
||||
// FMT_API auto vsystem_error(int error_code, string_view fmt, format_args args)
|
||||
// -> std::system_error;
|
||||
|
||||
/**
|
||||
* Constructs `std::system_error` with a message formatted with
|
||||
@@ -4212,11 +4212,11 @@ FMT_API auto vsystem_error(int error_code, string_view fmt, format_args args)
|
||||
* if (!file)
|
||||
* throw fmt::system_error(errno, "cannot open file '{}'", filename);
|
||||
*/
|
||||
template <typename... T>
|
||||
auto system_error(int error_code, format_string<T...> fmt, T&&... args)
|
||||
-> std::system_error {
|
||||
return vsystem_error(error_code, fmt.str, vargs<T...>{{args...}});
|
||||
}
|
||||
// template <typename... T>
|
||||
// auto system_error(int error_code, format_string<T...> fmt, T&&... args)
|
||||
// -> std::system_error {
|
||||
// return vsystem_error(error_code, fmt.str, vargs<T...>{{args...}});
|
||||
// }
|
||||
|
||||
/**
|
||||
* Formats an error message for an error returned by an operating system or a
|
||||
@@ -4231,8 +4231,8 @@ auto system_error(int error_code, format_string<T...> fmt, T&&... args)
|
||||
* message corresponding to the error code.
|
||||
* `error_code` is a system error code as given by `errno`.
|
||||
*/
|
||||
FMT_API void format_system_error(detail::buffer<char>& out, int error_code,
|
||||
const char* message) noexcept;
|
||||
// FMT_API void format_system_error(detail::buffer<char>& out, int error_code,
|
||||
// const char* message) noexcept;
|
||||
|
||||
// Reports a system error without throwing an exception.
|
||||
// Can be used to report errors from destructors.
|
||||
|
||||
5
third_party/fmt/include/fmt/xchar.h
vendored
5
third_party/fmt/include/fmt/xchar.h
vendored
@@ -291,8 +291,9 @@ inline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {
|
||||
auto buf = wmemory_buffer();
|
||||
detail::vformat_to(buf, fmt, args);
|
||||
buf.push_back(L'\0');
|
||||
if (std::fputws(buf.data(), f) == -1)
|
||||
FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
||||
std::fputws(buf.data(), f);
|
||||
// if (std::fputws(buf.data(), f) == -1)
|
||||
// FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
||||
}
|
||||
|
||||
inline void vprint(wstring_view fmt, wformat_args args) {
|
||||
|
||||
1
third_party/fmt/moz.yaml
vendored
1
third_party/fmt/moz.yaml
vendored
@@ -22,6 +22,7 @@ vendoring:
|
||||
patches:
|
||||
- print-null-string.patch
|
||||
- use-double-conversion.patch
|
||||
- comment-format-system-error.patch
|
||||
|
||||
exclude:
|
||||
- test
|
||||
|
||||
Reference in New Issue
Block a user