1
0
forked from 0ad/0ad

Fixes stack overflow in stack dump logic, by special-casing boost::unordered types, fixes #1813.

Adds INIT_HAVE_DISPLAY_ERROR init flag to correctly override
ah_display_error in Atlas (InitVfs was overriding it again), but don't
use it because it's ugly and broken, refs #1729

This was SVN commit r13724.
This commit is contained in:
historic_bruno 2013-08-20 21:07:42 +00:00
parent 3843ae6bb0
commit f947fa6afe
5 changed files with 30 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010 Wildfire Games
/* Copyright (c) 2013 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -1442,6 +1442,12 @@ static bool udt_fits_on_one_line(const wchar_t* type_name, size_t child_count, s
static Status udt_dump_normal(const wchar_t* type_name, const u8* p, size_t size, DumpState state, ULONG numChildren, const DWORD* children)
{
// special case: boost::unordered types are complex and may cause a stack overflow
// see http://trac.wildfiregames.com/ticket/1813
// TODO: at least give some info about them
if(!wcsncmp(type_name, L"boost::unordered", 16))
return INFO::CANNOT_HANDLE;
const bool fits_on_one_line = udt_fits_on_one_line(type_name, numChildren, size);
// prevent infinite recursion just to be safe (shouldn't happen)

View File

@ -434,10 +434,12 @@ static std::vector<CStr> GetMods(const CmdLineArgs& args, bool dev)
return mods;
}
static void InitVfs(const CmdLineArgs& args)
static void InitVfs(const CmdLineArgs& args, int flags)
{
TIMER(L"InitVfs");
const bool setup_error = (flags & INIT_HAVE_DISPLAY_ERROR) == 0;
const Paths paths(args);
OsPath logs(paths.Logs());
@ -449,7 +451,8 @@ static void InitVfs(const CmdLineArgs& args)
AppHooks hooks = {0};
hooks.bundle_logs = psBundleLogs;
hooks.get_log_dir = psLogDir;
hooks.display_error = psDisplayError;
if (setup_error)
hooks.display_error = psDisplayError;
app_hooks_update(&hooks);
const size_t cacheSize = ChooseCacheSize();
@ -469,7 +472,7 @@ static void InitVfs(const CmdLineArgs& args)
{
size_t priority = (i+1)*2; // mods are higher priority than regular mountings, which default to priority 0
size_t userFlags = VFS_MOUNT_WATCH|VFS_MOUNT_ARCHIVABLE|VFS_MOUNT_REPLACEABLE;
size_t flags = userFlags|VFS_MOUNT_MUST_EXIST;
size_t baseFlags = userFlags|VFS_MOUNT_MUST_EXIST;
OsPath modName(mods[i]);
if (dev)
@ -477,13 +480,13 @@ static void InitVfs(const CmdLineArgs& args)
// We are running a dev copy, so only mount mods in the user mod path
// if the mod does not exist in the data path.
if (DirectoryExists(modPath / modName/""))
g_VFS->Mount(L"", modPath / modName/"", flags, priority);
g_VFS->Mount(L"", modPath / modName/"", baseFlags, priority);
else
g_VFS->Mount(L"", modUserPath / modName/"", userFlags, priority);
}
else
{
g_VFS->Mount(L"", modPath / modName/"", flags, priority);
g_VFS->Mount(L"", modPath / modName/"", baseFlags, priority);
// Ensure that user modified files are loaded, if they are present
g_VFS->Mount(L"", modUserPath / modName/"", userFlags, priority+1);
}
@ -864,14 +867,14 @@ void EarlyInit()
bool Autostart(const CmdLineArgs& args);
void Init(const CmdLineArgs& args, int UNUSED(flags))
void Init(const CmdLineArgs& args, int flags)
{
h_mgr_init();
// Do this as soon as possible, because it chdirs
// and will mess up the error reporting if anything
// crashes before the working directory is set.
InitVfs(args);
InitVfs(args, flags);
// This must come after VFS init, which sets the current directory
// (required for finding our output log files).

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2013 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -42,7 +42,11 @@ enum InitFlags
// skip initializing the in-game GUI.
// needed by map editor because it uses its own GUI.
INIT_NO_GUI = 2
INIT_NO_GUI = 2,
// avoid setting display_error app hook
// needed by map editor because it has its own wx error display
INIT_HAVE_DISPLAY_ERROR = 4
};
/**

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2013 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -117,9 +117,12 @@ static void* RunEngine(void* data)
RegisterHandlers();
// Override ah_display_error to pass all errors to the Atlas UI
// TODO: this doesn't work well because it doesn't pause the game thread
// and the error box is ugly, so only use it if we fix those issues
// (use INIT_HAVE_DISPLAY_ERROR init flag to test this)
AppHooks hooks = {0};
hooks.display_error = AtlasDisplayError;
app_hooks_update(&hooks);
//app_hooks_update(&hooks);
// Disable the game's cursor rendering
extern CStrW g_CursorName;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2013 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -37,6 +37,7 @@
namespace AtlasMessage {
// see comment in GameLoop.cpp about ah_display_error before using INIT_HAVE_DISPLAY_ERROR
const int g_InitFlags = INIT_HAVE_VMODE|INIT_NO_GUI;
MESSAGEHANDLER(Init)