mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-20 08:52:22 +01:00
[util] Fix __wine_dbg_output crash with very long lines
This sometimes happens with Vulkan validation layers enabled.
This commit is contained in:
parent
f3c320b490
commit
c764dd97a6
@ -78,10 +78,32 @@ namespace dxvk {
|
||||
|
||||
if (!adjusted.empty()) {
|
||||
#ifdef _WIN32
|
||||
if (m_wineLogOutput)
|
||||
if (m_wineLogOutput) {
|
||||
// __wine_dbg_output tries to buffer lines up to 1020 characters
|
||||
// including null terminator, and will cause a hang if we submit
|
||||
// anything longer than that even in consecutive calls. Work
|
||||
// around this by splitting long lines into multiple lines.
|
||||
constexpr size_t MaxDebugBufferLength = 1018;
|
||||
|
||||
if (adjusted.size() <= MaxDebugBufferLength) {
|
||||
m_wineLogOutput(adjusted.c_str());
|
||||
else
|
||||
} else {
|
||||
std::array<char, MaxDebugBufferLength + 2u> buffer;
|
||||
|
||||
for (size_t i = 0; i < adjusted.size(); i += MaxDebugBufferLength) {
|
||||
size_t size = std::min(adjusted.size() - i, MaxDebugBufferLength);
|
||||
|
||||
std::strncpy(buffer.data(), &adjusted[i], size);
|
||||
if (buffer[size - 1u] != '\n')
|
||||
buffer[size++] = '\n';
|
||||
|
||||
buffer[size] = '\0';
|
||||
m_wineLogOutput(buffer.data());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cerr << adjusted;
|
||||
}
|
||||
#else
|
||||
std::cerr << adjusted;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user