Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Screensaver crash fix #2009

Merged
merged 3 commits into from

3 participants

@jimfcarroll
Collaborator

It appears that we are running out of Tls (Thread local storage) slots on Windows (which has a very limited number of them). The current codebase uses a new one per add Window instance. This collapses that use to a single instance for all windows.

Closes #13859

Jim Carroll added some commits
Jim Carroll [fix] It appears that we were running out of Tls on windows. This cha…
…nges the addon system so that a single one is created for the Interceptor functionality rather than one per window.
c49b8ea
Jim Carroll Add better error checking to the Windows ThreadLocal implementation. d1f6ee7
Jim Carroll Remove some unused includes of ThreadLocal.h 988e51b
@jmarshallnz
Owner

Looks good to me.

@davilla davilla merged commit 27781a9 into xbmc:master
@jimfcarroll jimfcarroll deleted the jimfcarroll:screensaver-crash-fix branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 31, 2012
  1. [fix] It appears that we were running out of Tls on windows. This cha…

    Jim Carroll authored
    …nges the addon system so that a single one is created for the Interceptor functionality rather than one per window.
  2. Remove some unused includes of ThreadLocal.h

    Jim Carroll authored
This page is out of date. Refresh to see the latest.
View
2  xbmc/interfaces/legacy/Window.cpp
@@ -37,6 +37,8 @@ namespace XBMCAddon
{
namespace xbmcgui
{
+ XbmcThreads::ThreadLocal<ref> InterceptorBase::upcallTls;
+
/**
* Used in add/remove control. It only locks if it's given a
* non-NULL CCriticalSection. It's given a NULL CCriticalSection
View
3  xbmc/interfaces/legacy/WindowInterceptor.h
@@ -43,7 +43,8 @@ namespace XBMCAddon
{
protected:
AddonClass::Ref<Window> window;
- XbmcThreads::ThreadLocal<ref> upcallTls;
+ // This instance is in Window.cpp
+ static XbmcThreads::ThreadLocal<ref> upcallTls;
InterceptorBase() : window(NULL) { upcallTls.set(NULL); }
View
1  xbmc/interfaces/python/LanguageHook.h
@@ -28,7 +28,6 @@
#include <Python.h>
#include "interfaces/legacy/LanguageHook.h"
-#include "threads/ThreadLocal.h"
#include "threads/Event.h"
#include <set>
View
1  xbmc/interfaces/python/swig.h
@@ -27,7 +27,6 @@
#include "interfaces/legacy/Exception.h"
#include "interfaces/legacy/AddonClass.h"
#include "interfaces/legacy/Window.h"
-#include "threads/ThreadLocal.h"
namespace PythonBindings
{
View
19 xbmc/threads/platform/win/ThreadLocal.h
@@ -21,6 +21,7 @@
#pragma once
#include <windows.h>
+#include "commons/Exception.h"
namespace XbmcThreads
{
@@ -32,11 +33,23 @@ namespace XbmcThreads
{
DWORD key;
public:
- inline ThreadLocal() { key = TlsAlloc(); }
+ inline ThreadLocal()
+ {
+ if ((key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
+ throw XbmcCommons::UncheckedException("Ran out of Windows TLS Indexes. Windows Error Code %d",(int)GetLastError());
+ }
- inline ~ThreadLocal() { TlsFree(key); }
+ inline ~ThreadLocal()
+ {
+ if (!TlsFree(key))
+ throw XbmcCommons::UncheckedException("Failed to free Tls %d, Windows Error Code %d",(int)key, (int)GetLastError());
+ }
- inline void set(T* val) { TlsSetValue(key,(LPVOID)val); }
+ inline void set(T* val)
+ {
+ if (!TlsSetValue(key,(LPVOID)val))
+ throw XbmcCommons::UncheckedException("Failed to set Tls %d, Windows Error Code %d",(int)key, (int)GetLastError());
+ }
inline T* get() { return (T*)TlsGetValue(key); }
};
Something went wrong with that request. Please try again.