proper unicode support for windows stack traces

This commit is contained in:
Eric 2023-06-08 16:57:21 -07:00
parent 01064e7960
commit 9f92a68ca3
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
7 changed files with 58 additions and 41 deletions

56
.efrocachemap generated
View File

@ -4072,26 +4072,26 @@
"build/assets/workspace/ninjafightplug.py": "https://files.ballistica.net/cache/ba1/c5/09/4f10b8a21ba87aa5509cff7a164b",
"build/assets/workspace/onslaughtplug.py": "https://files.ballistica.net/cache/ba1/ff/0a/a354984f9c074dab0676ac7e4877",
"build/assets/workspace/runaroundplug.py": "https://files.ballistica.net/cache/ba1/2a/1c/9ee5db6d1bceca7fa6638fb8abde",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/6b/af/77143d27fc8d029928c5e1bb10c7",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/85/76/121d40e717c2de145d6dca273642",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/1c/23/18d7ef96170aa3062abb354f2273",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/12/a9/99703794b4cc389f320721d94aae",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/80/32/2efd24f59072f1cb879b0f200655",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/21/46/cef78dedb759770ff165dae9c926",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/84/fc/0b6d71d75f4bd63f62fa7b980dbb",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/eb/81/93908c54010e63084ac763e65fed",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/f7/06/a66e097cd58666d098a38b700bdc",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/e1/f9/8fcb8ff917dc0b2d2f06d8e43fd2",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c4/8c/a7b9933f30c839ec5b9ad46e6584",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d2/0f/7b312ae1f670cc9144208303e61c",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/c1/dd/c7e2c05c76b12bbe4b3ff6a2461a",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/74/6c/c2283283605425d3a3c8b60adbb8",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e6/77/ecf7fc23cb0bed38be8f1779dd02",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d7/21/776c71a0d8536ef13186c053cde4",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/ca/a0/40a94450ef233e76c6d0a34164b1",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/9b/0e/ac0aaf7253be3e379c8e32b0d29f",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/71/43/0f2794f1da00b2169b3e4652341e",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/b0/f5/8539056667c96d4bbe170073f74e",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/2a/bf/5ec0907b7ea2ae9ce556bfbaa977",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/b6/90/05fcb5913ac0efa57a0fe9cdb24e",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d5/9c/a39c893eb6f006a229ae677d7d1f",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/4d/bc/a448dcc9cf0de969e9ab1d723b72",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/89/6b/3661b8151586a16adb80a52c293f",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/be/7d/333edec3e78c3b0f06c7a29571d1",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/06/da/1bd3481ad7c525f537f963352131",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b8/9a/ad6ecd60091315a0aa31ca55f736",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/3a/73/6cfd57cf5a424767fd7adcf0a2db",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/53/6f/30d29940df133fa78db5b7c3298c",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b8/7c/41db8ce4cfece1553f07b891ab34",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/73/cb/2a8b7d0a208147be97198cf3a59c",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/97/56/3af6d1fb98c1e9a637f803c45aa5",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/4f/26/74f101b0d6f038070a025dfb8c0c",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a8/12/1e10c0eb9b55408e6e4d3041cbf4",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/eb/5f/50df0e0f91b1c6fe76de7c7fd048",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/85/3f/dc233392f6d02a62dcad599d264d",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/23/2e/78b07a81552a79d67631075f2632",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/26/0e/1900fb42f7080dd62e35607d6d6d",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/c9/28/c98b86c13cfabd168d8683744cf5",
"build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/58/55/b6ae6dd4f3615fa87bb170a43233",
"build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b9/f8/37285d0ced7794a82534d13c33ac",
"build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c7/cc/0c5f0afbfa0ddabaea8d5838562a",
@ -4108,14 +4108,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/96/2e/1b0ba43fe24fe9cc223a434db647",
"build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f3/83/581b7df96f6516032a0747b83e15",
"build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/6a/6d/7aaf7617929eeff41bc5a574e6c8",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/55/c6/3e32ba9707e85f406ea329a00c21",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/4f/40/fc458ef6f3d7bcffb1f2998986d4",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/78/56/b042fdc52d047dce785cef6c1cb1",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/83/7a/33e42ec87ed9b0f3d42ae196efbf",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/91/24/0b00221d14389ae8ae7bd256f1e2",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/05/01/0c0f852d345d6b0cc64d254625bd",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/43/6b/d56519105aa22a01bc910f08c959",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/f7/fc/e25e5116bca1e0f647b725316fc0",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/4c/5b/e6f257859efef56c7bf8a16efb8c",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/be/ac/470e69d1b87eb9a6bb33d2039c4e",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/91/e9/2fc1d723e470d368a4160ed03f67",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/67/2c/ed2086d173cc6e75bd0df57f430c",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/c7/d0/2ed1069a23bc3f2e044e0eb6d493",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/4f/57/5965c82b8374280182436f235aac",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/97/ca/30e53a2369274ab60e4f9f764476",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/b7/16/5bac6aacbe4f663a2ff842338eab",
"src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa",
"src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1",
"src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/75/9f/bcf597b362c9f2480cb348188bdd",

View File

@ -1,4 +1,4 @@
### 1.7.20 (build 21075, api 8, 2023-06-08)
### 1.7.20 (build 21077, api 8, 2023-06-08)
- This seems like a good time for a `refactoring` release in anticipation of
changes coming in 1.8. Basically this means that a lot of things will be
@ -305,6 +305,10 @@
traces are not available.
- (build 21074) Added `babase.native_stack_trace()` to fetch native stack traces
as strings.
- (build 21076) Hopefully fixed a 'file in use' error for `_appstate_dump_tb` on
windows. Please holler if you are still seeing this. This file gets written
for debugging whenever the logic thread remains unresponsive for several
seconds.
### 1.7.19 (build 20997, api 7, 2023-01-19)

View File

@ -138,13 +138,13 @@ meta-clean:
# (except for a few things such as localconfig.json).
clean:
$(CHECK_CLEAN_SAFETY)
rm -rf build
rm -rf build # Handle this part ourself; can confuse git.
git clean -dfx $(ROOT_CLEAN_IGNORES)
# Show what clean would delete without actually deleting it.
clean-list:
$(CHECK_CLEAN_SAFETY)
@echo Would remove build # We do this ourself; not git.
@echo Would remove build # Handle this part ourself; can confuse git.
git clean -dnx $(ROOT_CLEAN_IGNORES)
# Build/update dummy python modules.

View File

@ -234,7 +234,7 @@ def print_corrupt_file_error() -> None:
_babase.apptimer(2.0, _babase.getsimplesound('error').play)
_tbfiles: list[TextIO] = []
_tb_held_files: list[TextIO] = []
@ioprepped
@ -298,11 +298,12 @@ def dump_app_state(
os.path.dirname(_babase.app.config_file_path), '_appstate_dump_tb'
)
tbfile = open(tbpath, 'w', encoding='utf-8')
# faulthandler needs the raw file descriptor to still be valid when
# it fires, so stuff this into a global var to make sure it doesn't get
# cleaned up.
tbfile = open(tbpath, 'w', encoding='utf-8')
_tbfiles.append(tbfile)
_tb_held_files.append(tbfile)
if delay > 0.0:
faulthandler.dump_traceback_later(delay, file=tbfile)
@ -329,6 +330,14 @@ def log_dumped_app_state() -> None:
os.path.dirname(_babase.app.config_file_path), '_appstate_dump_md'
)
if os.path.exists(mdpath):
# We may be hanging on to open file descriptors for use by
# faulthandler (see above). If we are, we need to clear them
# now or else we'll get 'file in use' errors below when we
# try to unlink it on windows.
for heldfile in _tb_held_files:
heldfile.close()
_tb_held_files.clear()
with open(mdpath, 'r', encoding='utf-8') as infile:
metadata = dataclass_from_json(
DumpedAppStateMetadata, infile.read()

View File

@ -28,7 +28,7 @@ if TYPE_CHECKING:
# Build number and version of the ballistica binary we expect to be
# using.
TARGET_BALLISTICA_BUILD = 21075
TARGET_BALLISTICA_BUILD = 21077
TARGET_BALLISTICA_VERSION = '1.7.20'
_g_env_config: EnvConfig | None = None

View File

@ -14,6 +14,8 @@
/* clang-format off */
// Builds fail if this is further up.
// This define gives us the unicode version.
#define DBGHELP_TRANSLATE_TCHAR
#include <dbghelp.h>
/* clang-format on */
@ -119,22 +121,24 @@ auto CorePlatformWindows::FormatWinStackTraceForDisplay(
SymFromAddr(win_sym_process_, address, NULL, symbol);
if (SymGetLineFromAddr64(win_sym_process_, address, &displacement,
&line)) {
const char* filename = line.FileName;
std::string filename_s = UTF8Encode(std::wstring(line.FileName));
const char* filename = filename_s.c_str();
if (!build_src_dir.empty()
&& !strncmp(filename, build_src_dir.c_str(),
build_src_dir.size())) {
filename += build_src_dir.size();
}
snprintf(linebuf, sizeof(linebuf),
"%-3d %s in %s: line: %lu: address: 0x%p\n", i, symbol->Name,
filename, line.LineNumber,
reinterpret_cast<void*>(symbol->Address));
"%-3d %s in %s: line: %lu: address: 0x%p\n", i,
UTF8Encode(std::wstring(symbol->Name)).c_str(), filename,
line.LineNumber, reinterpret_cast<void*>(symbol->Address));
} else {
snprintf(linebuf, sizeof(linebuf),
"SymGetLineFromAddr64 returned error code %lu.\n",
GetLastError());
snprintf(linebuf, sizeof(linebuf), "%-3d %s, address 0x%p.\n", i,
symbol->Name, reinterpret_cast<void*>(symbol->Address));
UTF8Encode(std::wstring(symbol->Name)).c_str(),
reinterpret_cast<void*>(symbol->Address));
}
out += linebuf;
}

View File

@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int {
namespace ballistica {
// These are set automatically via script; don't modify them here.
const int kEngineBuildNumber = 21075;
const int kEngineBuildNumber = 21077;
const char* kEngineVersion = "1.7.20";
auto MonolithicMain(const core::CoreConfig& core_config) -> int {