Commit Graph

94 Commits

Author SHA1 Message Date
Ryan Hummer
4af2fd066d Updating Dev-Release-5.5 from Main at CL #36144969
#okforversepublic

[CL 36146571 by Ryan Hummer in Dev-5.5 branch]
2024-09-10 10:26:02 -04:00
ben clayton
f64f4f7837 [AutoRTFM] Prevent memory corruption with stack writes in non-scoped transactions
Assert if you attempt to perform a write to the transaction-stack while in non-scoped transaction (writes to a Closed() scope are permitted).

Code changes:

Introduce FStackRange to hold a stack pointer range.

Use FStackRange in FContext for storing the true stack range for the thread.

Add a FStackRange to each FTransaction, and use this to ensure that write records aren't added to a transaction if the address is within the transaction's stack.
By having a serparate stack per transaction we can prevent stack writes making their way to a parent transaction's write log, reducing the amount of memory that may need to be tracked and simplifying the Undo logic.

Ensuring that the write log does not contain stack writes is required for the open-memory validator.

#rb neil.henning

[CL 36005508 by ben clayton in ue5-main branch]
2024-09-04 09:09:31 -04:00
neil henning
8049970d3a Make UNetConnection::Describe transactionally safe.
#rb ben.clayton, Brandon.Schaefer

[CL 36003849 by neil henning in ue5-main branch]
2024-09-04 07:37:01 -04:00
john stiles
25fb61bcd3 [AutoRTFM] Rename AutoRTFM::ForTheRuntime::RecordOpenWrite to AutoRTFM::RecordOpenWrite.
When dealing with external code, non-runtime may need to record writes in the open. For instance, the animation code uses the ISPC compiler, which is not natively RTFM-compatible, but we can run ISPC code in the open and manually track its writes.

#rb Brandon.Schaefer

[CL 35978986 by john stiles in ue5-main branch]
2024-09-03 15:59:53 -04:00
ben clayton
b32961058c [AutoRTFM] Add framework for safe open -> closed assignment, use it to fix memory leak with FText
Replace AutoRTFM::TIsSafeToReturnFromOpen with AutoRTFM::TAssignFromOpenToClosed.
This provides the same "is-it-safe-to-return-T" functionality, but also supports custom logic for safely copy-assigning or move-assigning a value from the open to the closed.

This is used to fix a memory leak with FText.

#rb neil.henning

[CL 35965187 by ben clayton in ue5-main branch]
2024-09-03 09:09:36 -04:00
ben clayton
291f1c19b9 [AutoRTFMTests] Fix / silence memory leaks in UObjectTests
Move GTestAnnotation from a global variable, and the FTestAnnotation type to test-local. Having this be global will be treated as a memory leak as the leak detector is run before global destructors.

Use MALLOCLEAK_IGNORE_SCOPE() for calling PerformGarbageCollectionWithIncrementalReachabilityAnalysis(). If the GC does not complete within the time limit, then it'll leak tasks that never complete. Unfortunately, I see no way to flush these.

#rb neil.henning

[CL 35964330 by ben clayton in ue5-main branch]
2024-09-03 07:55:10 -04:00
ben clayton
4c36187d8b [AutoRTFM] Fix some trivial memory leaks in the AutoRTFMTests
#rb neil.henning

[CL 35962368 by ben clayton in ue5-main branch]
2024-09-03 04:49:47 -04:00
ben clayton
225101e149 [AutoRTFM] Fix memory leaking from FUObjectItem::StatIDStringStorage
If the transaction was aborted between CreateStatID() and the FUObjectItem destructor, then the memory allocated in the open for the StatID was not freed.
Allocate the memory in the open, and carefully assign / reset StatIDStringStorage atomically in the open / abort handler.

Also fix / silence some other leaks in UECoreTests.cpp

#rb neil.henning

[CL 35962183 by ben clayton in ue5-main branch]
2024-09-03 04:20:17 -04:00
neil henning
76f16d0231 Make FConfigFile use a transactionally safe lock.
#rb ben.clayton

[CL 35956571 by neil henning in ue5-main branch]
2024-09-02 11:38:11 -04:00
john stiles
b43fd5f81c [AutoRTFM] Reland "Add PopAllOnAbortHandlers method."
This API deletes all pushed handlers for a given key. It is functionally equivalent to calling `PopOnAbortHandler` repeatedly, but more efficient.

#rb Brandon.Schaefer

[CL 35935689 by john stiles in ue5-main branch]
2024-08-30 15:53:21 -04:00
john stiles
873446ab15 [AutoRTFM] Expose IsInnerTransactionStack as public API.
This can be necessary when writing an OnAbort handler. We want to roll back changes to heap objects, but it's unsafe to roll back changes to objects on the inner-transaction's stack, so we need to be able to differentiate the two.

[CL 35934666 by john stiles in ue5-main branch]
2024-08-30 15:31:51 -04:00
john stiles
e7c07f7652 [Backout] - CL35929235
[FYI] john.stiles
Original CL Desc
-----------------------------------------------------------------
[AutoRTFM] Add PopAllOnAbortHandlers method.

This API deletes all pushed handlers for a given key. It is functionally equivalent to calling `PopOnAbortHandler` repeatedly, but more efficient.

[CL 35930214 by john stiles in ue5-main branch]
2024-08-30 12:41:48 -04:00
john stiles
d54abded99 [AutoRTFM] Add PopAllOnAbortHandlers method.
This API deletes all pushed handlers for a given key. It is functionally equivalent to calling `PopOnAbortHandler` repeatedly, but more efficient.

[CL 35929239 by john stiles in ue5-main branch]
2024-08-30 12:12:40 -04:00
neil henning
221311dbe6 Remove a bunch of the long deprecated APIs in AutoRTFM to clean out the header.
[CL 35652020 by neil henning in ue5-main branch]
2024-08-20 07:41:21 -04:00
ben clayton
f23ab35448 [AutoRTFM] Make UAIPerceptionSystem::UnregisterSource() transaction-safe
Add and use FRWTransactionallySafeAccessDetector, a transaction-safe version of FRWAccessDetector.
Use a FTransactionallySafeCriticalSection for UObjectDeleteListenersCritical.

#rb neil.henning

[CL 35622505 by ben clayton in ue5-main branch]
2024-08-19 07:24:22 -04:00
neil henning
2f665eee77 Add a SingleThreaded mode to TQueue and use it under AutoRTFM to fix a threading issue.
#rb ben.clayton

[CL 35622008 by neil henning in ue5-main branch]
2024-08-19 06:22:52 -04:00
ben clayton
3a9ebadef6 [AutoRTFM] Support returning values from AutoRTFM::Open() lambdas
#rb neil.henning

[CL 35568662 by ben clayton in ue5-main branch]
2024-08-15 13:27:55 -04:00
john stiles
b32b1b04cf [AutoRTFM] Add unit test for function pointers into standard-library functions
Fortunately, this seemed to work as expected and didn't expose any lurking issues.

#rb michael.nicolella

[CL 35552522 by john stiles in ue5-main branch]
2024-08-14 18:35:08 -04:00
ben clayton
7bcbbdd14c [AutoRTFM] Carefully destruct OnCommit / OnAbort functions
Abort tasks should be destructed immediately after being called, otherwise their destructors may depend on memory freed by a later task.
Commit tasks should be destructed before the abort handlers, again as they might depend on memory that is freed.

#rb michael.nicolella

[CL 35470950 by ben clayton in ue5-main branch]
2024-08-12 18:14:30 -04:00
brandon schaefer
b6c4245d86 Always open around creating GUID
#rb ben.clayton

[CL 35427217 by brandon schaefer in ue5-main branch]
2024-08-09 12:40:04 -04:00
michael nicolella
cdc3e6fb48 autortfmtests: suppress log pruning by passing -Multiprocess into the engine cmdline, since we run variants of the test suite in parallel using multiple processes and that causes races with pruning old log files
#rb neil.henning

[CL 35400946 by michael nicolella in ue5-main branch]
2024-08-08 13:23:25 -04:00
ben clayton
a5982b818f [AutoRTFMTests] Make tests pass on linux
* Use fopen() as a no-RTFM function instead of std::atomic_bool, as the latter has an inlined implementation on linux.
* Add missing tests for modf() and modff(). Add the missing modfl() registration which these caught.
* Fix RTFM_vswprintf() count calculations for non-windows. vswprintf() is horribly non-portable, and returns -1 if the buffer is too short.
* Adjust the printf tests to handle other non-portablity issues.
* Wrap wide string literals with std::wstring_view() when in REQUIRES(), as catch2 prints a bunch of '?' on error otherwise.

#rb neil.henning

[CL 35365141 by ben clayton in ue5-main branch]
2024-08-07 07:26:32 -04:00
neil henning
25f93ca257 Fix the FString::Printf problem which came down to a fun ODR violation in the MSVC CRT that AutoRTFM exposed.
[CL 35239578 by neil henning in ue5-main branch]
2024-08-01 05:07:41 -04:00
neil henning
70533f9372 Upgrade AutoRTFM_Enabled to apply to *all* Verse code.
#rb andy.sonnenburg, michael.nicolella

[CL 35171874 by neil henning in ue5-main branch]
2024-07-30 05:46:32 -04:00
neil henning
dea770125a Make setting and clearing UObject flags transactionally safe.
#rb ben.clayton

[CL 34910016 by neil henning in ue5-main branch]
2024-07-18 14:41:46 -04:00