Crash with setKioskModeComponent(nullptr...) in certain cases (win)


#1

when switching back from kiosk-mode, on windows, it can happen (not always) that the setKioskComponent method will reentry itself, and delete the kioskModeComponent pointer, while its still used in the first entry of the procedure (look at the callstack)

 

 	myApp.exe!juce::Desktop::setKioskModeComponent(juce::Component * componentToUse=0x00000000, bool allowMenusAndBars=true) Line 347	C++
 	myApp.exe!juce::HWNDComponentPeer::peerWindowProc(HWND__ * h=0x000304a2, unsigned int message=28, unsigned int wParam=0, long lParam=6456) Line 2483	C++
 	myApp.exe!juce::HWNDComponentPeer::windowProc(HWND__ * h=0x000304a2, unsigned int message=28, unsigned int wParam=0, long lParam=6456) Line 2308	C++
 	user32.dll!75507694()	Unknown
 	[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]	
 	user32.dll!75508baa()	Unknown
 	user32.dll!75508aa9()	Unknown
 	user32.dll!75508d56()	Unknown
 	user32.dll!75508d56()	Unknown
 	user32.dll!75508ee9()	Unknown
 	ntdll.dll!775add92()	Unknown
 	myApp.exe!juce::HWNDComponentPeer::destroyWindowCallback(void * handle=0x00060498) Line 1394	C++
 	myApp.exe!juce::HWNDComponentPeer::callFunctionIfNotLocked(void * (void *) * callback=0x0129faab, void * userData=0x00060498) Line 2318	C++
 	myApp.exe!juce::HWNDComponentPeer::~HWNDComponentPeer() Line 592	C++
 	myApp.exe!juce::HWNDComponentPeer::`scalar deleting destructor'(unsigned int)	C++
 	myApp.exe!juce::ContainerDeletePolicy::destroy(juce::ComponentPeer * object=0x0087ab18) Line 48	C++
 	myApp.exe!juce::ScopedPointer::~ScopedPointer() Line 100	C++
 	myApp.exe!juce::Component::addToDesktop(int styleWanted=505, void * nativeWindowToAttachTo=0x00000000) Line 706	C++
 	myApp.exe!juce::TopLevelWindow::recreateDesktopWindow() Line 262	C++
 	myApp.exe!juce::TopLevelWindow::setUsingNativeTitleBar(bool shouldUseNativeTitleBar=true) Line 251	C++
 	myApp.exe!juce::Desktop::setKioskComponent(juce::Component * kioskModeComponent_=0x0087a918, bool enableOrDisable=false, bool __formal=true) Line 3240	C++
 	myApp.exe!juce::Desktop::setKioskModeComponent(juce::Component * componentToUse=0x00000000, bool allowMenusAndBars=true) Line 366	C++
>	myApp.exe!MainWindow::perform(const juce::ApplicationCommandTarget::InvocationInfo & info={...}) Line 1013	C++
 	myApp.exe!juce::ApplicationCommandTarget::tryToInvoke(const juce::ApplicationCommandTarget::InvocationInfo & info={...}, bool async=false) Line 67	C++
 	myApp.exe!juce::ApplicationCommandTarget::invoke(const juce::ApplicationCommandTarget::InvocationInfo & info={...}, const bool async=false) Line 145	C++
 	myApp.exe!juce::ApplicationCommandManager::invoke(const juce::ApplicationCommandTarget::InvocationInfo & inf={...}, bool asynchronously=false) Line 187	C++
 	myApp.exe!juce::KeyPressMappingSet::invokeCommand(const int commandID=8388640, const juce::KeyPress & key={...}, const bool isKeyDown=true, const int millisecsSinceKeyPressed=0, juce::Component * originatingComponent=0x0087a918) Line 206	C++
 	myApp.exe!juce::KeyPressMappingSet::keyPressed(const juce::KeyPress & key={...}, juce::Component * originatingComponent=0x0087a918) Line 330	C++
 	myApp.exe!juce::ComponentPeer::handleKeyPress(int keyCode=65658, unsigned int textCharacter=0) Line 197	C++
 	myApp.exe!juce::HWNDComponentPeer::doKeyDown(const unsigned int key=122) Line 2024	C++
 	myApp.exe!juce::HWNDComponentPeer::peerWindowProc(HWND__ * h=0x00060498, unsigned int message=256, unsigned int wParam=122, long lParam=5701633) Line 2429	C++
 	myApp.exe!juce::HWNDComponentPeer::windowProc(HWND__ * h=0x00060498, unsigned int message=256, unsigned int wParam=122, long lParam=5701633) Line 2308	C++

The crash will happen here, because Desktop::kioskModeComponent is nullptr

First-chance exception at 0x01347B1F in myApp.exe: 0xC0000005: Access violation reading location 0x00000018.
Unhandled exception at 0x01347B1F in myApp.exe: 0xC0000005: Access violation reading location 0x00000018.


>	myApp.exe!juce::Rectangle::getWidth() Line 110	C++
 	myApp.exe!juce::Component::getWidth() Line 268	C++
 	myApp.exe!juce::Component::setBounds(int x=558, int y=247, int w=1041, int h=807) Line 1165	C++
 	myApp.exe!juce::Component::setBounds(const juce::Rectangle & r={...}) Line 1268	C++
 	myApp.exe!juce::Desktop::setKioskModeComponent(juce::Component * componentToUse=0x00000000, bool allowMenusAndBars=true) Line 371	C++
 	myApp.exe!MainWindow::perform(const juce::ApplicationCommandTarget::InvocationInfo & info={...}) Line 1013	C++
 	myApp.exe!juce::ApplicationCommandTarget::tryToInvoke(const juce::ApplicationCommandTarget::InvocationInfo & info={...}, bool async=false) Line 67	C++
 	myApp.exe!juce::ApplicationCommandTarget::invoke(const juce::ApplicationCommandTarget::InvocationInfo & info={...}, const bool async=false) Line 145	C++
 	myApp.exe!juce::ApplicationCommandManager::invoke(const juce::ApplicationCommandTarget::InvocationInfo & inf={...}, bool asynchronously=false) Line 187	C++
 	myApp.exe!juce::KeyPressMappingSet::invokeCommand(const int commandID=8388640, const juce::KeyPress & key={...}, const bool isKeyDown=true, const int millisecsSinceKeyPressed=0, juce::Component * originatingComponent=0x0087a918) Line 206	C++
 	myApp.exe!juce::KeyPressMappingSet::keyPressed(const juce::KeyPress & key={...}, juce::Component * originatingComponent=0x0087a918) Line 330	C++
 	myApp.exe!juce::ComponentPeer::handleKeyPress(int keyCode=65658, unsigned int textCharacter=0) Line 197	C++
 	myApp.exe!juce::HWNDComponentPeer::doKeyDown(const unsigned int key=122) Line 2024	C++
 	myApp.exe!juce::HWNDComponentPeer::peerWindowProc(HWND__ * h=0x00060498, unsigned int message=256, unsigned int wParam=122, long lParam=5701633) Line 2429	C++
 	myApp.exe!juce::HWNDComponentPeer::windowProc(HWND__ * h=0x00060498, unsigned int message=256, unsigned int wParam=122, long lParam=5701633) Line 2308	C++

Also i have two other issues with Fullscreen-Mode
On Windows the non-native Menu is missing after switching back, and on Mac the place where the native menus was, isn’t used by the fullscreen window, you see the background picture of the desktop.

(btw the forum page needs to be larger, to view callstacks without line breaks)


#2

maybe you could check for reentrance (with a static counter) in setKioskModeComponent, when componentToUse is already zero, just jump out of the method


#3

Thanks, I'll have a look at that..


#4

Thanks for fixing this :)

But, the kioskmode still doesnt work correct (as in older versions)

On Windows the non-native Menu is missing after switching back (resizing the window and it will reappear)

On Mac the place where the native menus was, isn't used by the fullscreen window, you see the background picture of the desktop.

 


#5

I use the kiosk mode in things like the juce demo and tracktion, and it seems to work fine. Can you give me some code to test that shows this problem?


#6

mhh, i have no idea why it works with the JUCE-Demo, but not in my current project, i also check the OS-X Compatibility Version and Base SDK (XCode 5.1 on 10.9.2)

So i created a simple test, a new project from the Introjucer, which only sets the kiosk mode when clicking on the content component, and it shows the same WRONG behavior (All settings in the introjucer are the default ones, on XCode 5.1 on 10.9.2 with the latest tip, the same i run the demo from)

(And it seems it doesn't use the smooth mountain lion Full screen animation)

Any idea what this can be, do i have overlooked something?

class MainContentComponent   : public Component
{
public:
    //==============================================================================
    MainContentComponent();
    ~MainContentComponent();

    void mouseDown (const MouseEvent& event) override
    {
        Desktop::getInstance().setKioskModeComponent(getTopLevelComponent());
    }



#7

ok, try again now..


#8

no difference on mac side, windows not checked yet


#9

I definitely fixed it on the mac.


#10

ah, sorry - okay somehow git, doesn't update my file

 

sorry, complete offtopic shouldn't this overwrite all my local changes?

i never git it ;)


git fetch --all

git reset --hard origin/master
 


#11

ahhh my mistake, didn't realized, that the default introjucer setting was copying a own version of the juce sourcecode for every project ;)


#12

thanks for fixing this, but there is one problem left on windows,

when using a MenuBar (via setMenuBar)

after exiting KioskMode, the MenuBar is missing, because in 

DocumentWindow::getContentComponentBorder()

isKioskMode() will still return true.

I have to resize the window, and the MenuBar will appear again...

 

BorderSize<int> DocumentWindow::getContentComponentBorder()
{
    BorderSize<int> border (getBorderThickness());
    if (! isKioskMode())
 


#13

bump


#14

ok, try again now.


#15

thanks fixed :)

Found another minor bug (on windows, with native borders) , if a window is maximized, than switching into kiosk mode and back, the window is a little misaligned, and not maximized anymore.