From fcdef29504a32ad85ce32c3d95ea8648aa169004 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Mon, 2 Jun 2025 07:09:27 +0800 Subject: Stop trying to force OpenGL version on non-macOS Turns out my old GPU is detected as complying only to 4.5 when on Linux. The fact that it's been detected as complying to 4.6 on FreeBSD this whole time, is quite ironic. I've only tested that the viewer runs with 4.6 without this on FreeBSD (the implication works), will test Linux distros next. --- indra/llwindow/llwindowsdl.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 69332e36b6..53092e4f2e 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -376,11 +376,9 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthBits); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBits); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); #if LL_DARWIN + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); -#else - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6); #endif SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); -- cgit v1.3 From 2e6dd2843b6b7c287783393ade1892568896a5a0 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Mon, 2 Jun 2025 08:02:39 +0800 Subject: Revert "Stop trying to force OpenGL version on non-macOS" This reverts commit fcdef29504a32ad85ce32c3d95ea8648aa169004. The moment 1 or 2 lines got removed, we lost core profile again. --- indra/llwindow/llwindowsdl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 53092e4f2e..69332e36b6 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -376,9 +376,11 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthBits); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBits); -#if LL_DARWIN SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); +#if LL_DARWIN SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); +#else + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6); #endif SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); -- cgit v1.3 From 9bae19198fdc7bfb71f900cfe6c1982cb2a80e4f Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 3 Jun 2025 16:20:27 +0800 Subject: Revert "Fix up llexception.h's cross-platform SEH wrapper." This reverts commit 5ed8df22cd59680a685c4ada7daa5555bf59d4fe. --- indra/llcommon/always_return.h | 16 ------ indra/llcommon/llexception.cpp | 24 ++++++--- indra/llcommon/llexception.h | 104 +++++++++++++++------------------------ indra/llwindow/llwindowwin32.cpp | 2 +- indra/test/test.cpp | 2 +- 5 files changed, 59 insertions(+), 89 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llcommon/always_return.h b/indra/llcommon/always_return.h index b99eb49096..a206471da5 100644 --- a/indra/llcommon/always_return.h +++ b/indra/llcommon/always_return.h @@ -79,22 +79,6 @@ namespace LL DESIRED mDefault; }; - // specialize for AlwaysReturn - template <> - struct AlwaysReturn - { - public: - AlwaysReturn() {} - - // callable returns a type not convertible to DESIRED, return default - template - void operator()(CALLABLE&& callable, ARGS&&... args) - { - // discard whatever callable(args) returns - std::forward(callable)(std::forward(args)...); - } - }; - /** * always_return(some_function, some_args...) calls * some_function(some_args...). It is guaranteed to return a value of type diff --git a/indra/llcommon/llexception.cpp b/indra/llcommon/llexception.cpp index 107fdc2b2d..74b33f1e3b 100644 --- a/indra/llcommon/llexception.cpp +++ b/indra/llcommon/llexception.cpp @@ -101,36 +101,44 @@ void annotate_exception_(boost::exception& exc) static constexpr U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific static constexpr U32 STATUS_STACK_FULL = 0xC00000FD; -void LL::seh::fill_stacktrace(std::string& stacktrace, U32 code) +U32 ll_seh_filter( + std::string& stacktrace, + std::function filter, + U32 code, + struct _EXCEPTION_POINTERS* exception_infop) { - // Sadly, despite its diagnostic importance, trying to capture a - // stacktrace when the stack is already blown only terminates us faster. + // By the time the handler gets control, the stack has been unwound, + // so report the stack trace now at filter() time. + // Even though stack overflow is a problem we would very much like to + // diagnose, calling another function when the stack is already blown only + // terminates us faster. if (code == STATUS_STACK_FULL) { stacktrace = "(stack overflow, no traceback)"; } else { - stacktrace = to_string(boost::stacktrace::stacktrace()); + stacktrace = boost::stacktrace::stacktrace().to_string(); } + + return filter(code, exception_infop); } -U32 LL::seh::common_filter(U32 code, struct _EXCEPTION_POINTERS*) +U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS*) { if (code == STATUS_MSC_EXCEPTION) { - // C++ exception, don't stop at this handler + // C++ exception, go on return EXCEPTION_CONTINUE_SEARCH; } else { // This is a non-C++ exception, e.g. hardware check. - // Pass control into the handler block. return EXCEPTION_EXECUTE_HANDLER; } } -void LL::seh::rethrow(U32 code, const std::string& stacktrace) +void seh_rethrow(U32 code, const std::string& stacktrace) { std::ostringstream out; out << "Windows exception 0x" << std::hex << code; diff --git a/indra/llcommon/llexception.h b/indra/llcommon/llexception.h index f58a553eb3..3e50678b44 100644 --- a/indra/llcommon/llexception.h +++ b/indra/llcommon/llexception.h @@ -12,7 +12,6 @@ #if ! defined(LL_LLEXCEPTION_H) #define LL_LLEXCEPTION_H -#include "always_return.h" #include #include #include @@ -107,111 +106,90 @@ void log_unhandled_exception_(const char*, int, const char*, const std::string&) * Structured Exception Handling *****************************************************************************/ // this is used in platform-generic code -- define outside #if LL_WINDOWS -struct Windows_SEH_exception: public LLException +struct Windows_SEH_exception: public std::runtime_error { - Windows_SEH_exception(const std::string& what): LLException(what) {} + Windows_SEH_exception(const std::string& what): std::runtime_error(what) {} }; -namespace LL -{ -namespace seh -{ - #if LL_WINDOWS //------------------------------------------------------------- -void fill_stacktrace(std::string& stacktrace, U32 code); - -// wrapper around caller's U32 filter(U32 code, struct _EXCEPTION_POINTERS*) -// filter function: capture a stacktrace, if possible, before forwarding the -// call to the caller's filter() function -template -U32 filter_(std::string& stacktrace, FILTER&& filter, - U32 code, struct _EXCEPTION_POINTERS* exptrs) -{ - // By the time the handler gets control, the stack has been unwound, - // so report the stack trace now at filter() time. - fill_stacktrace(stacktrace, code); - return std::forward(filter)(code, exptrs); -} +#include +// triadic variant specifies try(), filter(U32, struct _EXCEPTION_POINTERS*), +// handler(U32, const std::string& stacktrace) +// stacktrace may or may not be available template -auto catcher_inner(std::string& stacktrace, - TRYCODE&& trycode, FILTER&& filter, HANDLER&& handler) +auto seh_catcher(TRYCODE&& trycode, FILTER&& filter, HANDLER&& handler) { + // don't try to construct a std::function at the moment of Structured Exception + std::function + filter_function(std::forward(filter)); + std::string stacktrace; __try { return std::forward(trycode)(); } - __except (filter_(stacktrace, - std::forward(filter), - GetExceptionCode(), GetExceptionInformation())) + __except (ll_seh_filter( + stacktrace, + filter_function, + GetExceptionCode(), + GetExceptionInformation())) { - return always_return( - std::forward(handler), GetExceptionCode(), stacktrace); + return std::forward(handler)(GetExceptionCode(), stacktrace); } } -// triadic variant specifies try(), filter(U32, struct _EXCEPTION_POINTERS*), -// handler(U32, const std::string& stacktrace) -// stacktrace may or may not be available -template -auto catcher(TRYCODE&& trycode, FILTER&& filter, HANDLER&& handler) -{ - // Construct and destroy this stacktrace string in the outer function - // because we can't do either in the function with __try/__except. - std::string stacktrace; - return catcher_inner(stacktrace, - std::forward(trycode), - std::forward(filter), - std::forward(handler)); -} - -// common_filter() handles the typical case in which we want our handler -// clause to handle only Structured Exceptions rather than explicitly-thrown -// C++ exceptions -U32 common_filter(U32 code, struct _EXCEPTION_POINTERS*); - -// dyadic variant specifies try(), handler(U32, stacktrace), assumes common_filter() +// dyadic variant specifies try(), handler(U32, stacktrace), assumes default filter template -auto catcher(TRYCODE&& trycode, HANDLER&& handler) +auto seh_catcher(TRYCODE&& trycode, HANDLER&& handler) { - return catcher(std::forward(trycode), - common_filter, - std::forward(handler)); + return seh_catcher( + std::forward(trycode), + seh_filter, + std::forward(handler)); } // monadic variant specifies try(), assumes default filter and handler template -auto catcher(TRYCODE&& trycode) +auto seh_catcher(TRYCODE&& trycode) { - return catcher(std::forward(trycode), rethrow); + return seh_catcher( + std::forward(trycode), + seh_filter, + seh_rethrow); } -[[noreturn]] void rethrow(U32 code, const std::string& stacktrace); +// SEH exception filtering for use in __try __except +// Separates C++ exceptions from C SEH exceptions +// Todo: might be good idea to do some kind of seh_to_msc_wrapper(function, ARGS&&); +U32 ll_seh_filter( + std::string& stacktrace, + std::function filter, + U32 code, + struct _EXCEPTION_POINTERS* exception_infop); +U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS* exception_infop); +void seh_rethrow(U32 code, const std::string& stacktrace); #else // not LL_WINDOWS ----------------------------------------------------- template -auto catcher(TRYCODE&& trycode, FILTER&&, HANDLER&&) +auto seh_catcher(TRYCODE&& trycode, FILTER&&, HANDLER&&) { return std::forward(trycode)(); } template -auto catcher(TRYCODE&& trycode, HANDLER&&) +auto seh_catcher(TRYCODE&& trycode, HANDLER&&) { return std::forward(trycode)(); } template -auto catcher(TRYCODE&& trycode) +auto seh_catcher(TRYCODE&& trycode) { return std::forward(trycode)(); } #endif // not LL_WINDOWS ----------------------------------------------------- -} // namespace LL::seh -} // namespace LL - #endif /* ! defined(LL_LLEXCEPTION_H) */ diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index a781e638ee..97bd789134 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -160,7 +160,7 @@ HGLRC SafeCreateContext(HDC &hdc) GLuint SafeChoosePixelFormat(HDC &hdc, const PIXELFORMATDESCRIPTOR *ppfd) { - return LL::seh::catcher([hdc, ppfd]{ return ChoosePixelFormat(hdc, ppfd); }); + return seh_catcher(ChoosePixelFormat(hdc, ppfd)); } //static diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 6e280819df..536c252d97 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -638,7 +638,7 @@ int main(int argc, char **argv) // a chained_callback subclass must be linked with previous mycallback->link(); - LL::seh::catcher( + seh_catcher( // __try [test_group] { -- cgit v1.3 From bbe51e86249114cac4716c391e267c499a52847a Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 3 Jun 2025 16:21:58 +0800 Subject: Revert "Promote seh_catcher() et al. to llexception.{h,cpp} for general use." This reverts commit 71d777ea126e7f02cb46c11bdb606094ca06f75c. --- indra/llcommon/llexception.cpp | 50 ++++------------------ indra/llcommon/llexception.h | 86 ++------------------------------------ indra/llwindow/llwindowwin32.cpp | 13 +++++- indra/newview/llappviewerwin32.cpp | 36 ++++++++++++++-- indra/test/test.cpp | 68 +++++++++++++++++++++++++++++- 5 files changed, 121 insertions(+), 132 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llcommon/llexception.cpp b/indra/llcommon/llexception.cpp index 74b33f1e3b..c0154a569f 100644 --- a/indra/llcommon/llexception.cpp +++ b/indra/llcommon/llexception.cpp @@ -15,12 +15,7 @@ #include "llexception.h" // STL headers // std headers -#include -#include #include -#if LL_WINDOWS -#include -#endif // LL_WINDOWS // external library headers #include #include @@ -34,6 +29,7 @@ // On Windows, header-only implementation causes macro collisions -- use // prebuilt library #define BOOST_STACKTRACE_LINK +#include #endif // LL_WINDOWS #include @@ -98,34 +94,15 @@ void annotate_exception_(boost::exception& exc) // For windows SEH exception handling we sometimes need a filter that will // separate C++ exceptions from C SEH exceptions -static constexpr U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific -static constexpr U32 STATUS_STACK_FULL = 0xC00000FD; +static const U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific -U32 ll_seh_filter( - std::string& stacktrace, - std::function filter, - U32 code, - struct _EXCEPTION_POINTERS* exception_infop) +U32 msc_exception_filter(U32 code, struct _EXCEPTION_POINTERS *exception_infop) { - // By the time the handler gets control, the stack has been unwound, - // so report the stack trace now at filter() time. - // Even though stack overflow is a problem we would very much like to - // diagnose, calling another function when the stack is already blown only - // terminates us faster. - if (code == STATUS_STACK_FULL) - { - stacktrace = "(stack overflow, no traceback)"; - } - else - { - stacktrace = boost::stacktrace::stacktrace().to_string(); - } - - return filter(code, exception_infop); -} + const auto stack = to_string(boost::stacktrace::stacktrace()); + LL_WARNS() << "SEH Exception handled (that probably shouldn't be): Code " << code + << "\n Stack trace: \n" + << stack << LL_ENDL; -U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS*) -{ if (code == STATUS_MSC_EXCEPTION) { // C++ exception, go on @@ -133,20 +110,9 @@ U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS*) } else { - // This is a non-C++ exception, e.g. hardware check. + // handle it return EXCEPTION_EXECUTE_HANDLER; } } -void seh_rethrow(U32 code, const std::string& stacktrace) -{ - std::ostringstream out; - out << "Windows exception 0x" << std::hex << code; - if (! stacktrace.empty()) - { - out << '\n' << stacktrace; - } - LLTHROW(Windows_SEH_exception(out.str())); -} - #endif //LL_WINDOWS diff --git a/indra/llcommon/llexception.h b/indra/llcommon/llexception.h index 3e50678b44..68e609444e 100644 --- a/indra/llcommon/llexception.h +++ b/indra/llcommon/llexception.h @@ -102,94 +102,14 @@ void crash_on_unhandled_exception_(const char*, int, const char*, const std::str log_unhandled_exception_(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, CONTEXT) void log_unhandled_exception_(const char*, int, const char*, const std::string&); -/***************************************************************************** -* Structured Exception Handling -*****************************************************************************/ -// this is used in platform-generic code -- define outside #if LL_WINDOWS -struct Windows_SEH_exception: public std::runtime_error -{ - Windows_SEH_exception(const std::string& what): std::runtime_error(what) {} -}; - -#if LL_WINDOWS //------------------------------------------------------------- - -#include - -// triadic variant specifies try(), filter(U32, struct _EXCEPTION_POINTERS*), -// handler(U32, const std::string& stacktrace) -// stacktrace may or may not be available -template -auto seh_catcher(TRYCODE&& trycode, FILTER&& filter, HANDLER&& handler) -{ - // don't try to construct a std::function at the moment of Structured Exception - std::function - filter_function(std::forward(filter)); - std::string stacktrace; - __try - { - return std::forward(trycode)(); - } - __except (ll_seh_filter( - stacktrace, - filter_function, - GetExceptionCode(), - GetExceptionInformation())) - { - return std::forward(handler)(GetExceptionCode(), stacktrace); - } -} - -// dyadic variant specifies try(), handler(U32, stacktrace), assumes default filter -template -auto seh_catcher(TRYCODE&& trycode, HANDLER&& handler) -{ - return seh_catcher( - std::forward(trycode), - seh_filter, - std::forward(handler)); -} -// monadic variant specifies try(), assumes default filter and handler -template -auto seh_catcher(TRYCODE&& trycode) -{ - return seh_catcher( - std::forward(trycode), - seh_filter, - seh_rethrow); -} +#if LL_WINDOWS // SEH exception filtering for use in __try __except // Separates C++ exceptions from C SEH exceptions // Todo: might be good idea to do some kind of seh_to_msc_wrapper(function, ARGS&&); -U32 ll_seh_filter( - std::string& stacktrace, - std::function filter, - U32 code, - struct _EXCEPTION_POINTERS* exception_infop); -U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS* exception_infop); -void seh_rethrow(U32 code, const std::string& stacktrace); - -#else // not LL_WINDOWS ----------------------------------------------------- - -template -auto seh_catcher(TRYCODE&& trycode, FILTER&&, HANDLER&&) -{ - return std::forward(trycode)(); -} - -template -auto seh_catcher(TRYCODE&& trycode, HANDLER&&) -{ - return std::forward(trycode)(); -} - -template -auto seh_catcher(TRYCODE&& trycode) -{ - return std::forward(trycode)(); -} +U32 msc_exception_filter(U32 code, struct _EXCEPTION_POINTERS *exception_infop); -#endif // not LL_WINDOWS ----------------------------------------------------- +#endif //LL_WINDOWS #endif /* ! defined(LL_LLEXCEPTION_H) */ diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 97bd789134..4fca74497f 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -160,7 +160,18 @@ HGLRC SafeCreateContext(HDC &hdc) GLuint SafeChoosePixelFormat(HDC &hdc, const PIXELFORMATDESCRIPTOR *ppfd) { - return seh_catcher(ChoosePixelFormat(hdc, ppfd)); + __try + { + return ChoosePixelFormat(hdc, ppfd); + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + // convert to C++ styled exception + // C exception don't allow classes, so it's a regular char array + char integer_string[32]; + sprintf(integer_string, "SEH, code: %lu\n", GetExceptionCode()); + throw std::exception(integer_string); + } } //static diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index ef609026ad..4f5fa53312 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -396,10 +396,17 @@ void ll_nvapi_init(NvDRSSessionHandle hSession) } } -int APIENTRY wWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - PWSTR pCmdLine, - int nCmdShow) +//#define DEBUGGING_SEH_FILTER 1 +#if DEBUGGING_SEH_FILTER +# define WINMAIN DebuggingWinMain +#else +# define WINMAIN wWinMain +#endif + +int APIENTRY WINMAIN(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + PWSTR pCmdLine, + int nCmdShow) { // Call Tracy first thing to have it allocate memory // https://github.com/wolfpld/tracy/issues/196 @@ -548,6 +555,27 @@ int APIENTRY wWinMain(HINSTANCE hInstance, return 0; } +#if DEBUGGING_SEH_FILTER +// The compiler doesn't like it when you use __try/__except blocks +// in a method that uses object destructors. Go figure. +// This winmain just calls the real winmain inside __try. +// The __except calls our exception filter function. For debugging purposes. +int APIENTRY wWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + PWSTR lpCmdLine, + int nCmdShow) +{ + __try + { + WINMAIN(hInstance, hPrevInstance, lpCmdLine, nCmdShow); + } + __except( viewer_windows_exception_handler( GetExceptionInformation() ) ) + { + _tprintf( _T("Exception handled.\n") ); + } +} +#endif + void LLAppViewerWin32::disableWinErrorReporting() { std::string executable_name = gDirUtilp->getExecutableFilename(); diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 536c252d97..09147a65a3 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -36,7 +36,6 @@ #include "linden_common.h" #include "llerrorcontrol.h" -#include "llexception.h" #include "lltut.h" #include "chained_callback.h" #include "stringize.h" @@ -57,6 +56,13 @@ #include #include +// On Mac, got: +// #error "Boost.Stacktrace requires `_Unwind_Backtrace` function. Define +// `_GNU_SOURCE` macro or `BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED` if +// _Unwind_Backtrace is available without `_GNU_SOURCE`." +#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED +#include + #include void wouldHaveCrashed(const std::string& message); @@ -506,6 +512,64 @@ void wouldHaveCrashed(const std::string& message) static LLTrace::ThreadRecorder* sMasterThreadRecorder = NULL; +// this is used in platform-generic code -- define outside #if LL_WINDOWS +struct Windows_SEH_exception: public std::runtime_error +{ + Windows_SEH_exception(const std::string& what): std::runtime_error(what) {} +}; + +#if LL_WINDOWS + +static constexpr U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific +static constexpr U32 STATUS_STACK_FULL = 0xC00000FD; + +U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS*) +{ + if (code == STATUS_MSC_EXCEPTION) + { + // C++ exception, go on -- but TUT is supposed to have caught those already?! + return EXCEPTION_CONTINUE_SEARCH; + } + else + { + // This is a non-C++ exception, e.g. hardware check. + // By the time the handler gets control, the stack has been unwound, + // so report the stack trace now at filter() time. + // Sadly, even though, at the time of this writing, stack overflow is + // the problem we would most like to diagnose, calling another + // function when the stack is already blown only terminates us faster. + if (code != STATUS_STACK_FULL) + { + std::cerr << boost::stacktrace::stacktrace() << std::endl; + } + // pass control into the handler block + return EXCEPTION_EXECUTE_HANDLER; + } +} + +template +void seh_catcher(CALLABLE0&& trycode, CALLABLE1&& handler) +{ + __try + { + trycode(); + } + __except (seh_filter(GetExceptionCode(), GetExceptionInformation())) + { + handler(GetExceptionCode()); + } +} + +#else // not LL_WINDOWS + +template +void seh_catcher(CALLABLE0&& trycode, CALLABLE1&&) +{ + trycode(); +} + +#endif // not LL_WINDOWS + int main(int argc, char **argv) { ll_init_apr(); @@ -652,7 +716,7 @@ int main(int argc, char **argv) } }, // __except - [mycallback](U32 code, const std::string& /*stacktrace*/) + [mycallback](U32 code) { static std::map codes = { { 0xC0000005, "Access Violation" }, -- cgit v1.3 From 9ac2e961e3649ca03e333103d851005f2003ddbb Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 3 Jun 2025 16:57:51 +0800 Subject: Re-include GLEXT.cmake, but for Windows only There doesn't seem to be glext.h on Windows, so we'll just use the package from LL for now. --- indra/cmake/CMakeLists.txt | 1 + indra/cmake/GLEXT.cmake | 4 +++- indra/cmake/LLWindow.cmake | 2 +- indra/llwindow/CMakeLists.txt | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index 746d242560..5525ac9f24 100644 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -24,6 +24,7 @@ set(cmake_SOURCE_FILES FindAutobuild.cmake FMODSTUDIO.cmake FreeType.cmake + GLEXT.cmake GLH.cmake GLM.cmake Havok.cmake diff --git a/indra/cmake/GLEXT.cmake b/indra/cmake/GLEXT.cmake index a780966f0c..f45b27e7b8 100644 --- a/indra/cmake/GLEXT.cmake +++ b/indra/cmake/GLEXT.cmake @@ -3,7 +3,9 @@ include(Prebuilt) include(GLH) add_library( ll::glext INTERFACE IMPORTED ) -use_system_binary(glext) +#use_system_binary(glext) +if (WINDOWS) use_prebuilt_binary(glext) +endif () diff --git a/indra/cmake/LLWindow.cmake b/indra/cmake/LLWindow.cmake index 34df3ad33b..007b8dfba6 100644 --- a/indra/cmake/LLWindow.cmake +++ b/indra/cmake/LLWindow.cmake @@ -1,7 +1,7 @@ # -*- cmake -*- include(Variables) -include(GLH) +include(GLEXT) include(Prebuilt) include_guard() diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 1f0820a9f6..d29bd5cde4 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -55,6 +55,7 @@ set(llwindow_LINK_LIBRARIES llfilesystem llxml ll::glm + ll::glext ll::uilibraries ll::SDL ) -- cgit v1.3 From dad8be14580b75af6fa0b97e41d5f8103e23acbe Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 3 Jun 2025 17:59:37 +0800 Subject: Exclude Windows from compiling SDL related files --- indra/llwindow/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index d29bd5cde4..6debd54665 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -64,7 +64,7 @@ include_directories(${CMAKE_SOURCE_DIR}/llrender) # Libraries on which this library depends, needed for Linux builds # Sort by high-level to low-level -if (NOT DARWIN) +if (NOT (DARWIN OR WINDOWS)) list(APPEND viewer_SOURCE_FILES llkeyboardsdl.cpp llwindowsdl.cpp -- cgit v1.3 From 89a6a94e4026e6f87f54dfe5214173b07f520fc5 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Thu, 26 Jun 2025 22:09:30 +0800 Subject: Disable direct input init on Win ARM64 for now This would be for joysticks & spacemouses, which aren't that urgent. This is disabled as it seems to be causing a segmentation fault on Windows ARM64. --- indra/llwindow/llwindowwin32.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 4fca74497f..64f20e65ca 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -576,6 +576,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, // Make an instance of our window then define the window class mhInstance = GetModuleHandle(NULL); +#if !_M_ARM64 // Init Direct Input - needed for joystick / Spacemouse LPDIRECTINPUT8 di8_interface; @@ -590,6 +591,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, { gDirectInput8 = di8_interface; } +#endif mSwapMethod = SWAP_METHOD_UNDEFINED; -- cgit v1.3 From dcb1bf8b508c4fb8303e2a1b4c4f64c58f3e0580 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 1 Jul 2025 19:15:29 +0800 Subject: Make Windows SDL-ready (in case we need to) --- indra/llwindow/llwindow.cpp | 26 +++++++++++++------------- indra/llwindow/llwindowsdl.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 4f3cc69c75..bff559591f 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -74,12 +74,12 @@ S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) LL_WARNS() << "OSMessageBox: " << text << LL_ENDL; #if LL_MESA_HEADLESS // !!! *FIX: (?) return OSBTN_OK; +#elif LL_SDL + result = OSMessageBoxSDL(text, caption, type); #elif LL_WINDOWS result = OSMessageBoxWin32(text, caption, type); -#elif LL_DARWIN && !LL_SDL +#elif LL_DARWIN result = OSMessageBoxMacOSX(text, caption, type); -#elif LL_SDL - result = OSMessageBoxSDL(text, caption, type); #else #error("OSMessageBox not implemented for this platform!") #endif @@ -259,12 +259,12 @@ bool LLWindow::copyTextToPrimary(const LLWString &src) // static std::vector LLWindow::getDynamicFallbackFontList() { -#if LL_WINDOWS +#if LL_SDL + return LLWindowSDL::getDynamicFallbackFontList(); +#elif LL_WINDOWS return LLWindowWin32::getDynamicFallbackFontList(); -#elif LL_DARWIN && !LL_SDL +#elif LL_DARWIN return LLWindowMacOSX::getDynamicFallbackFontList(); -#elif LL_SDL - return LLWindowSDL::getDynamicFallbackFontList(); #else return std::vector(); #endif @@ -273,12 +273,12 @@ std::vector LLWindow::getDynamicFallbackFontList() // static std::vector LLWindow::getDisplaysResolutionList() { -#if LL_WINDOWS +#if LL_SDL + return std::vector(); +#elif LL_WINDOWS return LLWindowWin32::getDisplaysResolutionList(); -#elif LL_DARWIN && !LL_SDL +#elif LL_DARWIN return LLWindowMacOSX::getDisplaysResolutionList(); -#else - return std::vector(); #endif } @@ -346,7 +346,7 @@ LLSplashScreen *LLSplashScreen::create() return 0; #elif LL_WINDOWS return new LLSplashScreenWin32; -#elif LL_DARWIN && !LL_SDL +#elif LL_DARWIN return new LLSplashScreenMacOSX; #else #error("LLSplashScreen not implemented on this platform!") @@ -359,7 +359,7 @@ void LLSplashScreen::show() { if (!gSplashScreenp) { -#if LL_WINDOWS && !LL_MESA_HEADLESS +#if LL_WINDOWS && !LL_MESA_HEADLESS && !LL_SDL gSplashScreenp = new LLSplashScreenWin32; #elif LL_DARWIN && !LL_SDL gSplashScreenp = new LLSplashScreenMacOSX; diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index 144216f658..076d7234bc 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -32,7 +32,7 @@ #include "llwindow.h" #include "lltimer.h" -#if !defined(__i386__) && !defined(__x86_64__) +#if !defined(__i386__) && !defined(__x86_64__) && !_M_X64 #define SDL_DISABLE_IMMINTRIN_H #endif #include "SDL2/SDL.h" -- cgit v1.3 From 9820b16404ba18a9a0103aa94c28ea452e0c99e6 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Thu, 3 Jul 2025 13:22:53 +0800 Subject: getCursorDelta isn't implemented if using SDL on Win --- indra/llwindow/llwindow.h | 2 +- indra/llwindow/llwindowheadless.h | 2 +- indra/newview/llviewerwindow.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 5e06e665f3..37e681c41b 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -92,7 +92,7 @@ public: virtual bool setCursorPosition(LLCoordWindow position) = 0; virtual bool getCursorPosition(LLCoordWindow *position) = 0; -#if LL_WINDOWS +#if LL_WINDOWS && !LL_SDL virtual bool getCursorDelta(LLCoordCommon* delta) = 0; #endif virtual void showCursor() = 0; diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h index 5696b69a59..acec401133 100644 --- a/indra/llwindow/llwindowheadless.h +++ b/indra/llwindow/llwindowheadless.h @@ -60,7 +60,7 @@ public: /*virtual*/ void toggleVSync(bool enable_vsync) override { } /*virtual*/ bool setCursorPosition(LLCoordWindow position) override {return false;} /*virtual*/ bool getCursorPosition(LLCoordWindow *position) override {return false;} -#if LL_WINDOWS +#if LL_WINDOWS && !LL_SDL /*virtual*/ bool getCursorDelta(LLCoordCommon* delta) override { return false; } #endif /*virtual*/ void showCursor() override {} diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 5c84346917..2b02d5165f 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3848,7 +3848,7 @@ void LLViewerWindow::updateLayout() void LLViewerWindow::updateMouseDelta() { -#if LL_WINDOWS +#if LL_WINDOWS && !LL_SDL LLCoordCommon delta; mWindow->getCursorDelta(&delta); S32 dx = delta.mX; -- cgit v1.3