Jinoh Kang (@iamahuman) commented about dlls/win32u/winstation.c:
- }
- object->session = session;
- return object;
+}
+struct session_object *get_shared_desktop( BOOL force ) +{
- struct user_thread_info *thread_info = get_user_thread_info();
- struct session_object *desktop;
- if (!thread_info->shared_desktop || force)
- {
if (!(desktop = get_thread_session_object( GetCurrentThreadId(), OBJECT_TYPE_DESKTOP ))) return NULL;
if (thread_info->shared_desktop) session_object_release( thread_info->shared_desktop );
thread_info->shared_desktop = desktop;
(Tentative review, feel free to skip for now if you don't think this is applicable.)
Once our cached desktop go stale (due to e.g., mapping growth), the old cache won't be freed until the next `get_shared_desktop` call or thread exit.
While the old stale cache is alive, it will hold a reference to the `shared_section`, which will coexist with new `shared_section` referenced by newer threads and/or desktops. (TODO: is this actually an issue? What's the maximum bound for this "leak"? The number of threads?)
Instead of invalidating it on next query, I think we should be actively freeing them instead. To do this, we would replace `force = invalid = TRUE` with some kind of a weak-ref scheme.