Skip to content

wxColourPickerCtrl->GetColour() method crashes PHP #111

Description

@raernon

The wxColourPickerCtrl->GetColour() method crashes PHP under windows. I've tried both x86 and x64 versions of wxPHP (wxphp-3.0.2.0-php5.4-x86.exe and wxphp-3.0.2.0-php5.5-x64.exe)
I've created a sample code with wxFormBuilder: I've dropped a colourpicker and a button control on a frame, all controls with default properties. The button has an onclick event which try to read the colourpicker actual colour value. When the button pressed, the PHP crashes.

<?php

class MyFrame1 extends wxFrame {

  function __construct( $parent=null ){
    parent::__construct ( $parent, wxID_ANY, wxEmptyString, wxDefaultPosition, new wxSize( 500,300 ), wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );

    $this->SetSizeHints( wxDefaultSize, wxDefaultSize );

    $bSizer1 = new wxBoxSizer( wxVERTICAL );

    $this->m_colourPicker1 = new wxColourPickerCtrl( $this, wxID_ANY, wxBLACK, wxDefaultPosition, wxDefaultSize, wxCLRP_DEFAULT_STYLE );
    $bSizer1->Add( $this->m_colourPicker1, 0, wxALL, 5 );

    $this->m_button1 = new wxButton( $this, wxID_ANY, "MyButton", wxDefaultPosition, wxDefaultSize, 0 );
    $bSizer1->Add( $this->m_button1, 0, wxALL, 5 );


    $this->SetSizer( $bSizer1 );
    $this->Layout();

    $this->Centre( wxBOTH );

    // Connect Events
    $this->m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, array($this, "m_button1_click") );
  }


  function __destruct( ){
  }


  // Virtual event handlers, overide them in your derived class
  function m_button1_click( $event ){
    //Edited here
    print_r($this->m_colourPicker1->GetColour());
  }

}

$main = new MyFrame1();
$main->Show();
wxEntry();

Activity

  1. halfer commented on Dec 4, 2015

    @halfer
    Contributor

    FYI this works fine on GNU/Linux/Ubuntu 14.04:

    colour-picker

    The print_r() doesn't show the contents, but this is normal behaviour in my experience - I expect the data is still available with the right properties/getters.

  2. halfer commented on Dec 4, 2015

    @halfer
    Contributor

    @raernon: what is your crash message? Would you take a screenshot?

  3. raernon commented on Dec 4, 2015

    @raernon
    Author

    @halfer: print_r() works in debug mode (using .wxphpd extension)
    This crash happens not just on wxColourPickerCtrl, but it happens on calling GetColour(), GetForegroundColour() or GetBackgroundColour() method in other objects too.
    Here are the screenshots after pressing MyButton:
    screen1
    screen2

  4. halfer commented on Dec 5, 2015

    @halfer
    Contributor

    @raernon: that's not an error message. There is a crash, but Windows has hidden it from you. Check your PHP or Windows logs to see what the issue is, and add it to this bug report.

  5. raernon commented on Dec 5, 2015

    @raernon
    Author

    @halfer: As I had written previously, it is really a crash and therefore there is no error message. I do not have debug tools on my windows system, so I cannot attach debug logs. That is the reason, that I cannot debug and solve the problem and make suggestion to correct it. All, that I can do is to report the phenomenon and attach a sample wxphp code which can help to reproduce the crash on windows 10.
    Beside this, I can attach a screenshot about application log from control panel, but it does not contain any additional information about the exact error:
    screen3

  6. halfer commented on Dec 5, 2015

    @halfer
    Contributor

    Your screenshot illustrates exactly the point I was making @raernon - thanks for adding it. Windows was hiding a great deal of information in your previous screenshot, but the new one adds more detail. I agree the new details aren't particularly self-explanatory, but it does at least include version numbers and fault codes. We also now know it is Windows 10, which might be relevant.

    Do you get this behaviour on any other versions of Windows? I don't run Windows at all myself, but running older versions through a virtual machine may help to determine if it's new on W10, or has always been an issue on Windows.

  7. halfer commented on Dec 5, 2015

    @halfer
    Contributor

    Do you get the crash if the print_r() is removed? I'm not clear whether exposing the palette is causing the crash, or clicking a colour.

  8. raernon commented on Dec 5, 2015

    @raernon
    Author

    I get the crash when I call the GetColour() method. It is independent from print_r() function. But it crashed on GetBackgroundColour() and GetForegroundColour() methods too.

  9. halfer commented on Dec 5, 2015

    @halfer
    Contributor

    OK. Would you be in a position to try this on any other versions of Windows? (I don't know what the cause is, just making suggestions to help someone digging into the internals in the future).

    @jgmdev: is there anything the OP can do to provide more detailed fault information from Windows? I wonder if there is a debugging mode available, for example?

  10. raernon commented on Dec 5, 2015

    @raernon
    Author

    I have installed vmware player, windows xp sp3 and the same crash happened, so this bug affects every windows builds.

  11. cye060 commented on Jun 7, 2016

    @cye060

    Here is a screenshot of the line of code with values of exception break. File is pickers.cpp line 479.

    exception

    Here is the Call Stack log for windows

    >   php_wxwidgets.dll!zim_php_wxColourPickerCtrl_GetColour(int ht=0, _zval_struct * return_value=0x0127dd50, _zval_struct * * return_value_ptr=0x00000000, _zval_struct * this_ptr=0x0128db88, int return_value_used=1) Line 479    C++
        php5.dll!zend_do_fcall_common_helper_SPEC(_zend_execute_data * execute_data=0x01262178) Line 643    C
        php5.dll!ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER(_zend_execute_data * execute_data=0x00000000) Line 757  C
        php5.dll!execute(_zend_op_array * op_array=0x0127f748) Line 410 C
        php5.dll!zend_call_function(_zend_fcall_info * fci=0x01262080, _zend_fcall_info_cache * fci_cache=0x009cd81c) Line 956  C
        php5.dll!call_user_function(_hashtable * function_table=0x00000000, _zval_struct * * object_pp=0x03dbda2c, _zval_struct * function_name=0x0127da68, _zval_struct * retval_ptr=0x009cd948, unsigned int param_count=1, _zval_struct * * params=0x009cd8f0) Line 721  C
        php_wxwidgets.dll!wxEvtHandler_php::onEvent(wxEvent & evnt={...}) Line 14328    C++
        php_wxwidgets.dll!wxAppConsoleBase::HandleEvent(wxEvtHandler * handler=0x03daf738, void(wxEvtHandler::*)(wxEvent &) func=0x5b6e7790, wxEvent & event={...}) Line 658    C++
        php_wxwidgets.dll!wxAppConsoleBase::CallEventHandler(wxEvtHandler * handler=0x03daf738, wxEventFunctor & functor={...}, wxEvent & event={...}) Line 669 C++
        php_wxwidgets.dll!wxEvtHandler::ProcessEventIfMatchesId(const wxEventTableEntryBase & entry={...}, wxEvtHandler * handler=0x03daf738, wxEvent & event={...}) Line 1383  C++
        php_wxwidgets.dll!wxEvtHandler::SearchDynamicEventTable(wxEvent & event={...}) Line 1831    C++
        php_wxwidgets.dll!wxEvtHandler::TryHereOnly(wxEvent & event={...}) Line 1574    C++
        php_wxwidgets.dll!wxEvtHandler::ProcessEvent(wxEvent & event={...}) Line 1484   C++
        php_wxwidgets.dll!wxEvtHandler::SafelyProcessEvent(wxEvent & event={...}) Line 1669 C++
        php_wxwidgets.dll!wxButton::SendClickEvent() Line 371   C++
        php_wxwidgets.dll!wxButton::MSWCommand(unsigned int param=0, unsigned short __formal=33545) Line 424    C++
        php_wxwidgets.dll!wxWindow::HandleCommand(unsigned short id_=33545, unsigned short cmd=0, HWND__ * control=0x00081468) Line 5222    C++
        php_wxwidgets.dll!wxFrame::HandleCommand(unsigned short id=33545, unsigned short cmd=0, HWND__ * control=0x00081468) Line 819   C++
        php_wxwidgets.dll!wxFrame::MSWWindowProc(unsigned int message=529512, unsigned int wParam=33545, long lParam=529512) Line 856   C++
        php_wxwidgets.dll!wxWndProc(HWND__ * hWnd=0x001a0640, unsigned int message=273, unsigned int wParam=33545, long lParam=529512) Line 2668    C++
        user32.dll!769862fa()   Unknown
        [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]    
        user32.dll!76986d3a()   Unknown
        user32.dll!7698966e()   Unknown
        user32.dll!769896d5()   Unknown
        comctl32.dll!72fb45a1() Unknown
        comctl32.dll!72fb4603() Unknown
        comctl32.dll!72fb448d() Unknown
        user32.dll!769862fa()   Unknown
        user32.dll!76986d3a()   Unknown
        user32.dll!769862fa()   Unknown
        php_wxwidgets.dll!wxWindow::MSWWindowProc(unsigned int message=514, unsigned int wParam=0, long lParam=720928) Line 3530    C++
        php_wxwidgets.dll!wxAnyButton::MSWWindowProc(unsigned int nMsg=514, unsigned int wParam=0, long lParam=720928) Line 659 C++
        php_wxwidgets.dll!wxButton::MSWWindowProc(unsigned int nMsg=514, unsigned int wParam=0, long lParam=720928) Line 443    C++
        php_wxwidgets.dll!wxWndProc(HWND__ * hWnd=0x00081468, unsigned int message=514, unsigned int wParam=0, long lParam=720928) Line 2668    C++
        user32.dll!769862fa()   Unknown
        user32.dll!76986d3a()   Unknown
        user32.dll!769877d3()   Unknown
        php_wxwidgets.dll!wxFrame::MSWDoTranslateMessage(wxFrame * frame=0x009ce1ac, tagMSG * pMsg=0x051af798) Line 734 C++
        php_wxwidgets.dll!wxGUIEventLoop::Dispatch() Line 229   C++
        php_wxwidgets.dll!wxEventLoopBase::Run() Line 76    C++
        php_wxwidgets.dll!wxAppConsoleBase::MainLoop() Line 380 C++
        php_wxwidgets.dll!wxEntryReal(int & argc=1, wchar_t * * argv=0x03daf920) Line 503   C++
        php_wxwidgets.dll!wxEntry(int & argc=1, wchar_t * * argv=0x03daf920) Line 181   C++
        php_wxwidgets.dll!zif_php_wxEntry(int ht=0, _zval_struct * return_value=0x0127da48, _zval_struct * * return_value_ptr=0x00000000, _zval_struct * this_ptr=0x00000000, int return_value_used=0) Line 179 C++
        php5.dll!zend_do_fcall_common_helper_SPEC(_zend_execute_data * execute_data=0x01262080) Line 643    C
        php5.dll!ZEND_DO_FCALL_SPEC_CONST_HANDLER(_zend_execute_data * execute_data=0x00000000) Line 2233   C
        php5.dll!execute(_zend_op_array * op_array=0x0127d8a0) Line 410 C
        php5.dll!zend_execute_scripts(int type=8, _zval_struct * * retval=0x00000000, int file_count=3, ...) Line 1329  C
        php5.dll!php_execute_script(_zend_file_handle * primary_file=0x009cf66c) Line 2502  C
        php.exe!do_cli(int argc=2, char * * argv=0x00c32f88) Line 990   C
        php.exe!main(int argc=2, char * * argv=0x00c32f88) Line 1367    C
        php.exe!__tmainCRTStartup() Line 586    C
        kernel32.dll!7663338a() Unknown
        ntdll.dll!77589902()    Unknown
        ntdll.dll!775898d5()    Unknown
    

    If you need any more debug information from windows let me know, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions