CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    May 2013
    Posts
    11

    Question Help request: QuickTime ActiveX Control Heap Corruption the second time I open a dial

    Hello everybody,

    I need to write a piece of code that opens a QuickTime VR image into an MFC Dialog.
    I drew a Dialog and put an "Apple QuickTime Control 2.0" into it.
    Then I created a Control variable in my Dialog class, called QtControl.
    In the OnInitDialog I set the file to open, calling the put_FileName of the control.

    I tested it by:

    - opening a dialog --> worked
    - closing it --> worked
    - opening again --> crashed. The error was:

    "Windows has triggered a breakpoint in TestOcx.exe.
    This may be due to a corruption of the heap, which indicates a bug in TestOcx.exe or any of the DLLs it has loaded.
    This may also be due to the user pressing F12 while TestOcx.exe has focus.
    The output window may have more diagnostic information."

    I tried many things and googled a lot, but the only way that I found to avoid this crash was hardcoding a valid URL in the QtControl resources at compile time.
    In other words, if I write a valid absolute path to a .mov into the URL property of the QtControl from Visual Studio and compile it, then it works.
    Obviously, I can't do this because the absolute Path is valid only on my PC.

    What I'm asking you is:

    - suggestion to solve this, or
    - any website where I can read or,
    - at worst, another implementation that is not based on the activeX and takes me 2 days of coding

    You may want to download a test application with the problem at this link

    Feel free to ask me any other detail, and any hint would be appreciated.

    Thanks in advance,
    E.Russo

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Quote Originally Posted by emarusso View Post
    I tried many things
    Nowhere do you mention that you tried to debug the problem using the debugger.
    and googled a lot
    Google doesn't solve these problems -- you need to actually debug the issue by launching the application under the debugger.
    In other words, if I write a valid absolute path to a .mov into the URL property of the QtControl from Visual Studio and compile it, then it works.
    Then that makes it easy if you debug both scenarios and see what different path or what functions are called for each situation.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    May 2013
    Posts
    11

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Hello,

    here's what I didn't explain in my last post. Every experiment has been done with the debugger attached.

    1. In Visual studio, I hardcoded into the URL property of my QuickTime ActiveX control a valid absolute path to a .mov file that was on my PC, say C:\something.mov

    in this case it works.

    2. I wanted to do something more flexible, so I compiled my program leaving the field empty, and setting it into the OnInitDialog method of the Dialog class that contains the control.

    in this case it throws exceptions when I close the dialog. I enabled the Exception flag into the debugger, and it catched the following first-chance one:

    First-chance exception at 0x773ac41f in TestOcx.exe: 0x0000071A: Remote procedure call was aborted

    this is the Call Stack:
    Code:
    >	KernelBase.dll!773ac41f() 	
     	[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]	
     	KernelBase.dll!773ac41f() 	
     	rpcrt4.dll!770c0e0b() 	
     	rpcrt4.dll!770c0d9a() 	
     	winsta.dll!6ae08930() 	
     	winsta.dll!6ae08981() 	
     	winsta.dll!6ae088ee() 	
     	rpcrt4.dll!7704b500() 	
     	rpcrt4.dll!7704b4b2() 	
     	rpcrt4.dll!7704d8b5() 	
     	rpcrt4.dll!7704dbc8() 	
     	rpcrt4.dll!7704db45() 	
     	rpcrt4.dll!7704de16() 	
     	rpcrt4.dll!7704dd5d() 	
     	rpcrt4.dll!7704daed() 	
     	winsta.dll!6ae08b18() 	
     	winsta.dll!6ae0baeb() 	
     	winsta.dll!6ae0baa2() 	
     	winsta.dll!6ae0ba49() 	
     	winsta.dll!6ae0b971() 	
     	QTOControl.dll!61bb4e29() 	
     	QTOControl.dll!61bb7d84() 	
     	QTOControl.dll!61bb0cfc()
    Then I passed the exception to the program and the following assert is thrown:

    wincore.cpp

    Code:
    LRESULT CALLBACK
    AfxWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
    {
    	// special message which identifies the window as using AfxWndProc
    	if (nMsg == WM_QUERYAFXWNDPROC)
    		return 1;
    
    	// all other messages route through message map
    	CWnd* pWnd = CWnd::FromHandlePermanent(hWnd);
    	ASSERT(pWnd != NULL);
    After ignoring 3 times the assert, the program seems to work.
    But sometimes it throws the exception that I mentioned in my first post and the application crashes.


    3. I tried to "Shutdown" in some way the quicktime player, by editing the OnClose method of the Dialog, but both didn't solve my problem.

    I tried to:
    - call the method "QuickTimeTerminate" of the control
    - set the URL to empty string


    That's it. If you need other info, I'm here... :-)

    Regards,
    emarusso

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Quote Originally Posted by emarusso View Post
    2. I wanted to do something more flexible, so I compiled my program leaving the field empty, and setting it into the OnInitDialog method of the Dialog class that contains the control.
    And how is this field set in terms of C++?

    In other words, a description of what you did is not enough. Show the actual code you claim sets this field. This is especially the case when it comes to strings, as it seems to be the case that too many persons make basic mistakes when it comes to handling string data in C++.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; May 20th, 2013 at 01:37 PM.

  5. #5
    Join Date
    May 2013
    Posts
    11

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    The code is here

    http://docs.google.com/file/d/0B7Mih...it?usp=sharing

    as I wrote in my first post.

    Here's the point where I set the URL:

    Code:
    BOOL CQuickTimeDlg::OnInitDialog()
    {
            CDialog::OnInitDialog();
    
            HICON hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_QUICKTIME));
            SetIcon(hIcon, FALSE);
    
            m_kQtControl.put_FileName(m_strURL);
            m_kQtControl.put_FullScreen(m_bFullscreen);
            m_kQtControl.put_MovieControllerVisible(m_bMovieControllerVisible);
    
            return TRUE;  // return TRUE unless you set the focus to a control
            // ECCEZIONE: le pagine delle propriet� OCX devono restituire FALSE
    }
    where m_strURL is a CString, whose value is written in the CQuickTimeDlg constructor.

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Quote Originally Posted by emarusso View Post
    m_kQtControl.put_FileName(m_strURL);
    And the function prototype for put_FileName is what exactly? Is it this?
    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

    If so, then a CString is not a BSTR.

    http://forums.codeguru.com/showthrea...String-to-BSTR
    http://www.flounder.com/cstring.htm#CString%20to%20BSTR

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; May 21st, 2013 at 04:48 AM.

  7. #7
    Join Date
    May 2013
    Posts
    11

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    No, the prototype is

    void put_FileName(LPCTSTR newValue).

    As written in QTControl.h, that I attached.

  8. #8
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Quote Originally Posted by emarusso View Post
    No, the prototype is

    void put_FileName(LPCTSTR newValue).

    As written in QTControl.h, that I attached.
    Try replacing

    Code:
    m_kQtControl.put_FileName(m_strURL);
    with

    Code:
    m_kQtControl.put_FileName(m_strURL.GetBuffer());
    m_strURL.ReleaseBuffer();
    to access the buffer contents of m_strURL.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  9. #9
    Join Date
    May 2013
    Posts
    11

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Nothing changes.

    I think the problem is somewhere else, because the assert is thrown by the destructor of
    COleControlSite, namely the method

    m_pInPlaceObject->InPlaceDeactivate();

    As far as I know, COleControlSite is the container of ActiveX controls, and the m_pInPlaceObject member is the control itself.

  10. #10
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Have you checked that the contents of m_strURL.GetBuffer() are correct? What happens if you hardcode the URL as in

    Code:
    m_kQtControl.put_FileName(_T("MyURL"));
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  11. #11
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Quote Originally Posted by emarusso View Post
    Nothing changes.

    I think the problem is somewhere else, because the assert is thrown by the destructor of
    COleControlSite, namely the method
    Sounds like heap corruption to me.

    First, does this entire application consist of more than one executable module (DLL, EXE)? If so, and if you're passing CString between executables, then you need to be careful ... more to the point, drop using it. You shouldn't pass classes that can potentially use the heap internally to other executable modules, the reason being that

    1) all modules must use the same heap manager, since CString uses the heap.

    2) The version of CString between the modules must be the exact same version. If you compiled one module one way, and then compiled another module with a set of different options, you would more than likely have two completely different versions of CString being used by the application, causing random crashes when you use it.

    Regards,

    Paul McKenzie

  12. #12
    Join Date
    May 2013
    Posts
    11

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Quote Originally Posted by 2kaud View Post
    Have you checked that the contents of m_strURL.GetBuffer() are correct? What happens if you hardcode the URL as in

    Code:
    m_kQtControl.put_FileName(_T("MyURL"));
    Nothing changes, the error's still there.

  13. #13
    Join Date
    May 2013
    Posts
    11

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Quote Originally Posted by Paul McKenzie View Post
    Sounds like heap corruption to me.
    First, does this entire application consist of more than one executable module (DLL, EXE)?
    Sounds like heap corruption to me too.
    In fact, when you try to open the dialog again,
    after having ignored the assertions, Visual Studio throws an error saying that heap corruption occurred.

    I think it's a QuickTime issue and there's nothing wrong in my code.

    Since I haven't found any code reference online,
    I posted here hoping that someone else had the same problem.

    The application is a MFC dialog app created with visual studio wizard, and uses the quickTime ActiveX.
    You may want to download it here:

    http://docs.google.com/file/d/0B7Mih...it?usp=sharing


    Thanks for your suggestions,
    emarusso

  14. #14
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    From your first post

    I tried many things and googled a lot, but the only way that I found to avoid this crash was hardcoding a valid URL in the QtControl resources at compile time.
    If hardcoding a valid URL in the control at compile does not cause the problem, then IMO the cause of the problem is unlikely to be the control. I would be looking at how I passed the URL to the control.

    Where do you hard code the URL? I suggested a test of a hardcoded URL in my post #10 but you replied that this still causes the problem. I don't understand - as in one post you say hardcoding the URL works and in another you say it doesn't.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  15. #15
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Help request: QuickTime ActiveX Control Heap Corruption the second time I open a

    Quote Originally Posted by emarusso View Post
    I think it's a QuickTime issue and there's nothing wrong in my code.
    Programmers get fired for saying that, and especially if they're using C++ where crashes can occur due to the fault of the programmer.

    Therefore, you must always assume it is your code unless you can prove without a doubt it isn't. My bet is that it is your code in some way, i.e. how it is built, or at runtime, some other errors you haven't detected.
    The application is a MFC dialog app created with visual studio wizard, and uses the quickTime ActiveX.
    You may want to download it here:
    So instead of this larger application, why not a much smaller one where all you're doing is using the control?

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; May 21st, 2013 at 12:08 PM.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured