Commit Graph

52 Commits (e00edbeb4a7edfe4f190ac7bf2197aa8240e50c6)

Author SHA1 Message Date
Andrey Kleshchev bb4d02446f SL-14347 Crash at ChoosePixelFormat SEH 2020-12-01 18:22:24 +02:00
Nat Goodspeed 0756885ead DRTVWR-476: make printActiveCoroutines() output slightly clearer.
For the main coroutine on each thread, show the 'main0' (or whatever) name
instead of the empty-string name.
2020-03-25 19:25:42 -04:00
Nat Goodspeed 39e7b48317 DRTVWR-476: Make llcoro::logname() distinguish different threads.
Actually, introduce static LLCoros::logname() and make the namespaced free
function an alias for that.

Because CoroData is a subclass of LLInstanceTracker with a key, every instance
requires a distinct key. That conflicts with our "getName() returns empty
string for default coroutine on thread" convention. Introduce a new CoroData
constructor, specifically for the default coroutine on each thread, that
initializes the getName() name to empty string while providing a distinct
"mainN" key. Make get_CoroData() use that new constructor for its thread_local
instance, passing an atomic<int> incremented each time we initialize one for a
new thread.

Then LLCoros::logname() returns either the getName() name or the key.
2020-03-25 19:24:25 -04:00
Nat Goodspeed 80f913fadb DRTVWR-476: Adjust LLCoros to new LLInstanceTracker API. 2020-03-25 19:24:25 -04:00
Nat Goodspeed 2a56ab4436 DRTVWR-476, SL-12197: Don't throw Stopping from main coroutine.
The new LLCoros::Stop exception is intended to terminate long-lived coroutines
-- not interrupt mainstream shutdown processing. Only throw it on an
explicitly-launched coroutine.

Make LLCoros::getName() (used by the above test) static. As with other LLCoros
methods, it might be called after the LLCoros LLSingleton instance has been
deleted. Requiring the caller to call instance() implies a possible need to
also call wasDeleted(). Encapsulate that nuance into a static method instead.
2020-03-25 19:24:25 -04:00
Nat Goodspeed 9008124d35 DRTVWR-476: Keep coroutine-local data on toplevel()'s stack frame.
Instead of heap-allocating a CoroData instance per coroutine, storing the
pointer in a ptr_map and deleting it from the ptr_map once the
fiber_specific_ptr for that coroutine is cleaned up -- just declare a stack
instance on the top-level stack frame, the simplest C++ lifespan management.
Derive CoroData from LLInstanceTracker to detect potential name collisions and
to enumerate instances.

Continue registering each coroutine's CoroData instance in our
fiber_specific_ptr, but use a no-op deleter function.

Make ~LLCoros() directly pump the fiber scheduler a few times, instead of
having a special "LLApp" listener.
2020-03-25 19:05:16 -04:00
Nat Goodspeed 26c8ccfc06 DRTVWR-476: Back out changeset 40c0c6a8407d ("final" LLApp listener) 2020-03-25 19:02:24 -04:00
Nat Goodspeed cbf146f2b3 DRTVWR-476: Pump coroutines a few more times when we start quitting.
By the time "LLApp" listeners are notified that the app is quitting, the
mainloop is no longer running. Even though those listeners do things like
close work queues and inject exceptions into pending promises, any coroutines
waiting on those resources must regain control before they can notice and shut
down properly. Add a final "LLApp" listener that resumes ready coroutines a
few more times.

Make sure every other "LLApp" listener is positioned before that new one.
2020-03-25 19:02:24 -04:00
Nat Goodspeed 28a54c2f7b DRTVWR-476: Infrastructure to help manage long-lived coroutines.
Introduce LLCoros::Stop exception, with subclasses Stopping, Stopped and
Shutdown. Add LLCoros::checkStop(), intended to be called periodically by any
coroutine with nontrivial lifespan. It checks the LLApp status and, unless
isRunning(), throws one of these new exceptions.

Make LLCoros::toplevel() catch Stop specially and log forcible coroutine
termination.

Now that LLApp status matters even in a test program, introduce a trivial
LLTestApp subclass whose sole function is to make isRunning() true.
(LLApp::setStatus() is protected: only a subclass can call it.) Add LLTestApp
instances to lleventcoro_test.cpp and lllogin_test.cpp.

Make LLCoros::toplevel() accept parameters by value rather than by const
reference so we can continue using them even after context switches.

Make private LLCoros::get_CoroData() static. Given that we've observed some
coroutines living past LLCoros destruction, making the caller call
LLCoros::instance() is more dangerous than encapsulating it within a static
method -- since the encapsulated call can check LLCoros::wasDeleted() first
and do something reasonable instead. This also eliminates the need for both a
const and non-const overload.

Defend LLCoros::delete_CoroData() (cleanup function for fiber_specific_ptr for
CoroData, implicitly called after coroutine termination) against calls after
~LLCoros().

Add a status string to coroutine-local data, with LLCoro::setStatus(),
getStatus() and RAII class TempStatus.

Add an optional 'when' string argument to LLCoros::printActiveCoroutines().
Make ~LLCoros() print the coroutines still active at destruction.
2020-03-25 19:02:24 -04:00
Anchor 243b111565 [DRTVWR-476] - compile error fix 2020-03-25 18:39:20 -04:00
Nat Goodspeed 101ab28f0c SL-793: Fix lllogin_test.cpp for new LLCoros implementation.
Delete the test for SRV timeout: lllogin no longer issues an SRV query. That
test only confuses the test program without exercising any useful paths in
production code.

As with other tests dating from the previous LLCoros implementation, we need a
few llcoro::suspend() calls sprinkled in so that a fiber marked ready -- by
fulfilling the future for which it is waiting -- gets a chance to run.

Clear LLEventPumps between test functions.
2020-03-25 18:39:20 -04:00
Nat Goodspeed 66981fab0b SL-793: Use Boost.Fiber instead of the "dcoroutine" library.
Longtime fans will remember that the "dcoroutine" library is a Google Summer
of Code project by Giovanni P. Deretta. He originally called it
"Boost.Coroutine," and we originally added it to our 3p-boost autobuild
package as such. But when the official Boost.Coroutine library came along
(with a very different API), and we still needed the API of the GSoC project,
we renamed the unofficial one "dcoroutine" to allow coexistence.

The "dcoroutine" library had an internal low-level API more or less analogous
to Boost.Context. We later introduced an implementation of that internal API
based on Boost.Context, a step towards eliminating the GSoC code in favor of
official, supported Boost code.

However, recent versions of Boost.Context no longer support the API on which
we built the shim for "dcoroutine." We started down the path of reimplementing
that shim using the current Boost.Context API -- then realized that it's time
to bite the bullet and replace the "dcoroutine" API with the Boost.Fiber API,
which we've been itching to do for literally years now.

Naturally, most of the heavy lifting is in llcoros.{h,cpp} and
lleventcoro.{h,cpp} -- which is good: the LLCoros layer abstracts away most of
the differences between "dcoroutine" and Boost.Fiber.

The one feature Boost.Fiber does not provide is the ability to forcibly
terminate some other fiber. Accordingly, disable LLCoros::kill() and
LLCoprocedureManager::shutdown(). The only known shutdown() call was in
LLCoprocedurePool's destructor.

We also took the opportunity to remove postAndSuspend2() and its associated
machinery: FutureListener2, LLErrorEvent, errorException(), errorLog(),
LLCoroEventPumps. All that dual-LLEventPump stuff was introduced at a time
when the Responder pattern was king, and we assumed we'd want to listen on one
LLEventPump with the success handler and on another with the error handler. We
have never actually used that in practice. Remove associated tests, of course.

There is one other semantic difference that necessitates patching a number of
tests: with "dcoroutine," fulfilling a future IMMEDIATELY resumes the waiting
coroutine. With Boost.Fiber, fulfilling a future merely marks the fiber as
ready to resume next time the scheduler gets around to it. To observe the test
side effects, we've inserted a number of llcoro::suspend() calls -- also in
the main loop.

For a long time we retained a single unit test exercising the raw "dcoroutine"
API. Remove that.

Eliminate llcoro_get_id.{h,cpp}, which provided llcoro::get_id(), which was a
hack to emulate fiber-local variables. Since Boost.Fiber has an actual API for
that, remove the hack.

In fact, use (new alias) LLCoros::local_ptr for LLSingleton's dependency
tracking in place of llcoro::get_id().

In CMake land, replace BOOST_COROUTINE_LIBRARY with BOOST_FIBER_LIBRARY. We
don't actually use the Boost.Coroutine for anything (though there exist
plausible use cases).
2020-03-25 17:32:45 -04:00
andreykproductengine b35a948ad8 SL-10908 Test viewers should crash normally 2019-08-06 21:29:51 +03:00
andreykproductengine 08fd73410e MAINT-8686 Don't log empty list 2018-06-22 20:49:40 +03:00
andreykproductengine 83dcf6b10d MAINT-8689 Diagnostics for coroutine memory crash 2018-05-14 14:07:36 +03:00
andreykproductengine 8348e50c7f MAINT-8686 Viewer should report active coroutines at the end of the session 2018-05-30 16:44:14 +03:00
Nat Goodspeed e3a2c5e321 DRTVWR-418: Merge from latest viewer-release 2017-11-29 14:47:09 -05:00
andreykproductengine 7d393759ba MAINT-7820 Additional crash logging 2017-10-05 16:03:49 +03:00
Nat Goodspeed 434f0e161a Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2017-02-03 09:54:52 -05:00
Nat Goodspeed 6c7a972861 DRTVWR-418: Fold windows64 into windows platform with new autobuild.
autobuild 1.1 now supports expanding $variables within a config file --
support that was explicitly added to address this very problem. So now the
windows platform in autobuild.xml uses $AUTOBUILD_ADDRSIZE,
$AUTOBUILD_WIN_VSPLATFORM and $AUTOBUILD_WIN_CMAKE_GEN, which should handle
most of the deltas between the windows platform and windows64.

This permits removing the windows64 platform definition from autobuild.xml.

The one remaining delta between the windows64 and windows platform definitions
was -DLL_64BIT_BUILD=TRUE. But we can handle that instead by checking
ADDRESS_SIZE. Change all existing references to WORD_SIZE to ADDRESS_SIZE
instead, and set ADDRESS_SIZE to $AUTOBUILD_ADDRSIZE. Change the one existing
LL_64BIT_BUILD reference to test (ADDRESS_SIZE EQUAL 64) instead.
2016-11-15 15:53:24 -05:00
Nat Goodspeed 704c53b3c5 MAINT-5232: Merge up to VLC viewer from viewer-release 2016-10-11 10:59:17 -04:00
Nat Goodspeed a601c559e8 MAINT-5232: Ensure that llcoro::get_id() returns distinct values.
Until now, the "main coroutine" (the initial context) of each thread left
LLCoros::Current() NULL. The trouble with that is that llcoro::get_id()
returns that CoroData* as an opaque token, and we want distinct values for
every stack in the process. That would not be true if the "main coroutine" on
thread A returned the same value (NULL) as the "main coroutine" on thread B,
and so forth. Give each thread's "main coroutine" a dummy heap CoroData
instance of its own.
2016-09-06 12:08:38 -04:00
Oz Linden 5edd4cecfc merge changes for exception handling 2016-09-06 11:07:39 -04:00
Oz Linden 72f4c72001 downgrade spammy LLCoros logging to DEBUG 2016-09-06 10:21:28 -04:00
Nat Goodspeed f931f6ef52 MAINT-5232: Add LLCoros::get_id() to identify the running coroutine.
Change the module-static thread_specific_ptr to a function-static
thread_specific_ptr so it will be initialized on demand -- since LLSingleton
will need to rely on get_id(). Note that since LLCoros isa LLSingleton, we
must take great care to avoid circularity.

Introduce a private helper class LLCoros::Current to obtain and bind that
thread_specific_ptr. Change all existing internal references from the static
thread_specific_ptr to the new Current helper class.
2016-09-03 11:39:17 -04:00
Nat Goodspeed abfe05c1b3 MAINT-5011: Add comments to LLCoros::toplevel() exception handlers. 2016-08-26 14:20:11 -04:00
Nat Goodspeed 17382b22e0 MAINT-5011: Remove unreferenced param name to avoid fatal warning 2016-08-25 14:04:36 -04:00
Nat Goodspeed 4d10172d8b MAINT-5011: Catch unhandled exceptions in LLCoros coroutines.
Wrap coroutine call in try/catch in top-level coroutine wrapper function
LLCoros::toplevel(). Distinguish exception classes derived from
LLContinueError (log and continue) from all others (crash with LL_ERRS).

Enhance CRASH_ON_UNHANDLED_EXCEPTIONS() and LOG_UNHANDLED_EXCEPTIONS() macros
to accept a context string to supplement the log message. This lets us replace
many places that called boost::current_exception_diagnostic_information() with
LOG_UNHANDLED_EXCEPTIONS() instead, since the explicit calls were mostly to
log supplemental information.

Provide supplemental information (coroutine name, function parameters) for
some of the previous LOG_UNHANDLED_EXCEPTIONS() calls. This information
duplicates LL_DEBUGS() information at the top of these functions, but in a
typical log file we wouldn't see the LL_DEBUGS() message.

Eliminate a few catch (std::exception e) clauses: the information we get from
boost::current_exception_diagnostic_information() in a catch (...) clause
makes it unnecessary to distinguish.

In a few cases, add a final 'throw;' to a catch (...) clause: having logged
the local context info, propagate the exception to be caught by higher-level
try/catch.

In a couple places, couldn't resist reconciling indentation within a
particular function: tabs where the rest of the function uses tabs, spaces
where the rest of the function uses spaces.

In LLLogin::Impl::loginCoro(), eliminate some confusing comments about an
array of rewritten URIs that date back to a long-deleted implementation.
2016-08-18 17:33:44 -04:00
Nat Goodspeed 6cc4a8dcd2 Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2016-11-03 09:31:15 -04:00
Nat Goodspeed 6f6c8fa5ff DRTVWR-418: Double coroutine stack size for 64-bit builds
on the advice of NickyD.
2016-06-28 18:27:39 -04:00
Oz Linden 9be58e915a merge with 4.0.3-release 2016-04-04 15:53:09 -04:00
Nat Goodspeed 6a062089b8 MAINT-5976: Introduce LLCoros::set_consuming(bool).
set_consuming(true) tells each postAndSuspend() call to consume the event for
which it is suspending.
2015-12-16 17:13:04 -05:00
Rider Linden 2af14639de MAINT-5835: Cut down on log spam from coros and voice. 2015-11-20 12:24:53 -08:00
Oz Linden c8726aba30 remove execute permission from many files that should not have it 2015-11-10 09:48:56 -05:00
Nat Goodspeed 68f42e4e10 MAINT-5351: Finish cleaning up messy merge from backing out backout 2015-07-10 19:44:47 -04:00
Nat Goodspeed 9bde72f784 Automated merge with file:///Users/nat/linden/maint-4952-v-t-u 2015-07-10 19:37:19 -04:00
Nat Goodspeed efa9a0f99c Backed out changeset bab1000e1b2d: restore 'selfless' changes 2015-07-10 19:30:10 -04:00
Nat Goodspeed 0c915913fd MAINT-5351: Improve management of "current" coroutine information.
Our first cut at tracking the "current" coroutine simply reset the pointer to
NULL every time we context-switched away. But that strategy doesn't handle the
case of coroutine A launching coroutine B.
Introduce LLCoros::CoroData to track, among other things, the previous value
of the current-coroutine pointer each time we switch into a coroutine. Restore
THAT value when we switch back out.
2015-07-10 16:01:15 -04:00
Rider Linden 247eb0c9c3 Backout selfles merge 738255dbbfd679d9e615baab3398e5e345bbb3c5 2015-07-07 19:41:27 +01:00
Nat Goodspeed f90023fc0b MAINT-5357: Introduce and populate llcoro:: namespace.
To date, the coroutine helper functions in lleventcoro.h have been in the
global namespace. Migrate them into llcoro namespace, and fix references.
Specifically, LLVoidListener => llcoro::VoidListener, and voidlistener(),
postAndWait(), both waitForEventOn(), postAndWait2(), errorException() and
errorLog() have been moved into llcoro.
Also migrate new LLCoros::get_self() and Suspending to llcoro:: namespace.
While at it, I realized that -- having converted several lleventcoro.h
functions from templates (for arbitrary 'self' parameter type) to ordinary
functions, having moved them from lleventcoro.h to lleventcoro.cpp, we can now
migrate their helpers from lleventcoro.h to lleventcoro.cpp as well. This
eliminates the need for the LLEventDetail namespace; the relevant helpers are
now in an anonymous namespace in the .cpp file: listenerNameForCoro(),
storeToLLSDPath(), WaitForEventOnHelper and wfeoh().
2015-07-02 17:00:32 -04:00
Nat Goodspeed b262ded7e0 MAINT-5351: Remove 'self' parameter from coroutine functions.
lleventcoro_test.cpp runs clean (as modified for new API), and all the rest
builds clean, but the resulting viewer is as yet untested.
2015-07-01 18:33:29 -04:00
Graham Madarasz 50689a13ba BOOG2707 uncomment cleared suspects 2013-06-05 06:14:27 -07:00
Graham Madarasz ea24612561 BUG-2707 make use of OsOutputDebugString _DEBUG only on Windows to avoid throwing unhandlable exceptions in coroutines in RelWithDebInfo builds 2013-06-04 07:51:27 -07:00
Graham Madarasz d21fc254a7 BUG-2707 hunt for infos call crashing Kat 2013-06-01 13:43:52 -07:00
Nat Goodspeed 3be79d5371 MAINT-2724: Make viewer explicitly set coroutine stack size.
Introduce LLCoros::setStackSize(), with a compile-time default value we hope
we never have to use. Make LLAppViewer call it with the value of the new
settings variable CoroutineStackSize as soon as we've read settings files.
(While we're at it, notify interested parties that we've read settings files.)
Give CoroutineStackSize a default value four times the previous default stack
size. Make LLCoros::launch() pass the saved stack size to each new coroutine
instance.
Re-enable lleventcoro integration test. Use LLSDMap() construct rather than
LLSD::insert(), which used to return the modified object but is now void.
2013-05-23 16:28:20 -04:00
Oz Linden 545e033d1e merge changes for DRTVWR-299 2013-05-07 15:11:55 -04:00
Graham Madarasz bf6182daa8 Update Mac and Windows breakpad builds to latest 2013-03-29 07:50:08 -07:00
Nat Goodspeed 54e2d2b000 MAINT-2389: Change viewer to Boost package without ucontext.h.
In autobuild.xml, specify today's build of the Boost package that includes the
Boost.Context library, and whose boost::dcoroutines library uses Boost.Context
exclusively instead of its previous context-switching underpinnings (source of
the ucontext.h dependency).
Add BOOST_CONTEXT_LIBRARY to Boost.cmake and Copy3rdPartyLibs.cmake. Link it
with the viewer and with the lllogin.cpp test executable.
Track new Boost package convention that our (early, unofficial) Boost.Coroutine
library is now accessed as boost/dcoroutine/etc.h and boost::dcoroutines::etc.
Remove #include <boost/coroutine/coroutine.hpp> from
llviewerprecompiledheaders.h and lllogin.cpp: old rule that Boost.Coroutine
header must be #included before anything else that might use ucontext.h is
gone now that we no longer depend on ucontext.h. In fact remove
-D_XOPEN_SOURCE in 00-Common.cmake because that was inserted specifically to
work around a known problem with the ucontext.h facilities.
2013-02-21 01:13:24 -05:00
Oz Linden 06b0d72efa Change license from GPL to LGPL (version 2.1) 2010-08-13 07:24:57 -04:00
Nat Goodspeed ec52e19dd1 DEV-32777, QAR-1619: Disable MSVC Release-build optimization for LLCoros::launchImpl().
This fixes the Release-build crash in lllogin_test.cpp.
2009-09-25 10:55:25 -04:00