Commit Graph

87 Commits (0953b6b646e5271a1c4b1ca032b5732c1fbdb635)

Author SHA1 Message Date
Ansariel 7ff7317779 Merge branch 'DRTVWR-521-maint' of https://bitbucket.org/lindenlab/viewer 2021-08-02 09:35:11 +02:00
Andrey Lihatskiy 6c8e6f033b Merge branch 'master' into DRTVWR-521-maint
# Conflicts:
#	autobuild.xml
#	indra/llcommon/llerror.cpp
#	indra/llui/llnotifications.h
#	indra/newview/llappviewer.cpp
#	indra/newview/llappviewermacosx.cpp
2021-07-20 02:48:05 +03:00
Andrey Kleshchev a6ea2dbedc SL-15292 Voice's singleton shutdown before voice's coroutine 2021-07-19 23:38:31 +03:00
Ansariel b1ba050b1f Merge branch 'DRTVWR-516-maint' of https://bitbucket.org/lindenlab/viewer 2021-04-30 23:29:58 +02:00
Ansariel 94534f4c88 Merge branch 'master' of https://vcs.firestormviewer.org/phoenix-firestorm 2021-04-30 23:25:06 +02:00
Ansariel db72dc7d0f Merge branch 'DRTVWR-516-maint' of https://bitbucket.org/lindenlab/viewer 2021-04-02 19:33:18 +02:00
Andrey Kleshchev ed98ebb811 SL-14961 Coroutine crash was not reported to bugsplat 2021-03-13 11:21:01 +02:00
Ansariel 6c587d437d Merge branch 'DRTVWR-515-maint' of https://bitbucket.org/lindenlab/viewer 2020-12-02 08:17:58 +01:00
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
Nicky Dasmijn a135b5b428 Merge remote-tracking branch 'origin/ll-vs2017' into fs-vs2017 2019-12-21 13:14:51 +01:00
Nicky Dasmijn 7f9bce5ada Merge branch 'master' into fs-vs2017 2019-12-21 01:52:19 +01:00
Nat Goodspeed be662c65ca 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.
2019-12-18 15:54:00 -05:00
Nat Goodspeed aa9a8d6b44 Automated merge with ssh://bitbucket.org/lindenlab/viewer-vs2017 2019-12-13 13:32:20 -05:00
Nat Goodspeed 218c0a1d4f Automated merge with ssh://bitbucket.org/nat_linden/viewer-llsingleton 2019-12-13 13:20:21 -05:00
Nat Goodspeed 3abbd0b196 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.
2019-12-10 10:56:24 -05:00
Nicky 9335eded97 Merge with viewer-vs2107 2019-12-08 17:18:43 +01:00
Nat Goodspeed 622bbc7e39 DRTVWR-476: Adjust LLCoros to new LLInstanceTracker API. 2019-12-05 11:54:52 -05:00
Nat Goodspeed 95c6b512e1 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.
2019-11-22 11:58:27 -05:00
Nicky fee98dac77 Merge with VS2017 2019-11-10 12:07:34 +01:00
Nat Goodspeed edd0ad6c79 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.
2019-10-25 06:55:45 -04:00
Nat Goodspeed 24d4f87afb DRTVWR-476: Back out changeset 40c0c6a8407d ("final" LLApp listener) 2019-10-24 16:05:37 -04:00
Nat Goodspeed 33c4170336 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.
2019-10-24 12:54:38 -04:00
Nat Goodspeed 71ec081dbf 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.
2019-10-22 16:49:29 -04:00
Ansariel daa60fdb2c Merge viewer-neko 2019-08-13 20:32:40 +02:00
andreykproductengine b35a948ad8 SL-10908 Test viewers should crash normally 2019-08-06 21:29:51 +03:00
Nicky e6e66a953e Merge with viewer-vs2017 2019-06-06 14:37:27 +02:00
Anchor be789451db [DRTVWR-476] - compile error fix 2019-04-30 16:30:36 -06:00
Nat Goodspeed 1e1e93c069 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.
2018-12-29 10:27:16 -05:00
Nat Goodspeed d2c581c344 Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2018-12-28 14:46:49 -05:00
Ansariel 7e8bf47559 Merge viewer-lynx 2018-07-02 19:43:10 +02:00
Ansariel 4c4b76ab37 Merge viewer-neko 2018-06-22 22:22:26 +02:00
andreykproductengine 08fd73410e MAINT-8686 Don't log empty list 2018-06-22 20:49:40 +03:00
Ansariel 106d34da3a Merge viewer-neko 2018-06-12 21:54:15 +02:00
andreykproductengine 8348e50c7f MAINT-8686 Viewer should report active coroutines at the end of the session 2018-05-30 16:44:14 +03:00
andreykproductengine 83dcf6b10d MAINT-8689 Diagnostics for coroutine memory crash 2018-05-14 14:07:36 +03:00
Nat Goodspeed 26570cfd67 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).
2018-05-10 21:46:07 -04:00
Ansariel 10ef44e77a Disable the special Windows handling too 2018-02-18 15:12:34 +01:00
Ansariel a0e19aabe4 Comment out catch-all exception handler for coroutines for hopefully more meaningful callstacks 2018-02-18 14:35:13 +01:00
Ansariel e7715f7a31 Merge Firestorm LGPL 2017-11-30 20:33:07 +01:00