List Info

Thread: Segmentation fault while using SetSize()




Segmentation fault while using SetSize()
country flaguser name
Netherlands
2007-10-02 03:49:50
Hi,

I'm experiencing a strange segmentation fault while using
SetSize(). I'm using wxPython version 2.8.6.0. I've
downloaded
the Debian-packages with the help from the Wiki. I'm also
using
Python version 2.5.1 (r251:54863, Aug 17 2007, 00:51:07).
Anyway, the python code below causes the trouble:

	self._panel.SetSize(
		(wx.Size(self._panel.GetSize()[0] + 1,
self._panel.GetSize()[1]))
	)

After this statement python segfaults on me. I've pinpointed
the
problem to the _wrap_Window_SetSize() function from the
wxPython/src/gtk/_core_wrap.cpp file and added some code
like
below to it (only the non-indented code is my add-on):

  {
    PyThreadState* __tstate = wxPyBeginAllowThreads();
printf("a: %p %pn",arg1,arg2);
{
	wxSize freddy;
	freddy = ((wxWindow const *)arg1)->GetSize();
	printf("GetSize() =
(%d,%d)n",freddy.x,freddy.y);
}
    (arg1)->SetSize((wxSize const &)*arg2);
printf("bn");
    wxPyEndAllowThreads(__tstate);
printf("cn");
    if (PyErr_Occurred()) SWIG_fail;
  }

When running, this gives me:

/* I start the application. */
a: 0x8482598 0x86c4300
GetSize() = (684,520)
b
c
/* I press a button and dive into a new menu with buttons.
*/
a: 0x8482598 0x86c4300
GetSize() = (685,520)
b
c
/* I press another button, which causes me to go back to
the
 * first menu with buttons. */
a: 0x8482598 0x86c4300
GetSize() = (684,520)
Segmentation fault
$ 

There is a little more to it. The problem started when I
changed the code
below:

    def init_ui(self, parent):
        # Load the panel from the resource file
        # Now create the panel from the resource data
        self._wxPanel =
wx.GetApp().resource.LoadPanel(parent, self._resourcename)

        # Show the panel
        self._wxPanel.Show()

        # Also return a reference to the panel
        return self._wxPanel

into:

    def load(self, parent):
        # Load the panel from the resource file
        # Now create the panel from the resource data
        self._wxPanel =
wx.GetApp().resource.LoadPanel(parent, self._resourcename)

        # Hide the panel!
        self._wxPanel.Hide()

    def init_ui(self, parent):
        # Show the panel
        self._wxPanel.Show()

        # Also return a reference to the panel
        return self._wxPanel

Since the init_ui took to long (600ms) I thought to remove
the
LoadPanel() to the start of the program. The init_ui() now
only
has to show the stuff and the loading is done only one time
in
advance. Maybe now some data is gone from memory, while
pointers
are still pointing to the memory???

The strange part is that the GetSize() works on that same
pointer. It's only the SetSize() that causes the trouble.

I'm not sure if this is a bug or some misunderstanding on my
part
about wx, so I'm asking this both on the development and
user
mailing list. Please include my emailadres in any reply,
since
I'm not member of both lists. Thanks for any help!


-- 
$ cat ~/.signature
Freddy Spierenburg <freddydusktilldawn.nl>  http://freddy.snarl.nl/
GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1  E588 6F17 FD5D
7941 D1E1
$ # Please read http://www.ietf.o
rg/rfc/rfc2015.txt before complain!
Re: Segmentation fault while using SetSize()
country flaguser name
United States
2007-10-02 14:41:56
Freddy Spierenburg wrote:
...
> 
>     def load(self, parent):
>         # Load the panel from the resource file
>         # Now create the panel from the resource data
>         self._wxPanel =
wx.GetApp().resource.LoadPanel(parent, self._resourcename)
> 
>         # Hide the panel!
>         self._wxPanel.Hide()
> 
>     def init_ui(self, parent):
>         # Show the panel
>         self._wxPanel.Show()
> 
>         # Also return a reference to the panel
>         return self._wxPanel
> 
> Since the init_ui took to long (600ms) I thought to
remove the
> LoadPanel() to the start of the program. The init_ui()
now only
> has to show the stuff and the loading is done only one
time in
> advance. Maybe now some data is gone from memory, while
pointers
> are still pointing to the memory???
> 
> The strange part is that the GetSize() works on that
same
> pointer. It's only the SetSize() that causes the
trouble.
> 
> I'm not sure if this is a bug or some misunderstanding
on my part
> about wx, so I'm asking this both on the development
and user
> mailing list. Please include my emailadres in any
reply, since
> I'm not member of both lists. Thanks for any help!

So where is the SetSize that is causing the trouble?

Can you make a small runnable same that shows the problem so
we can run 
it ourselves?


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java
give you jitters?  Relax with wxPython!


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


Re: Segmentation fault while using SetSize()
country flaguser name
Netherlands
2007-10-03 05:27:33
Hi Robin, On Tue, Oct 02, 2007 at 12:41:56PM -0700, Robin Dunn wrote: > So where is the SetSize that is causing the trouble? It's on line 262 of the file ui_wx.py. If you dive into this the way I did, you will find out that the GetSize() works, but the SetSize() causes the segmentation fault. See my previous mail for further detail. > Can you make a small runnable same that shows the problem so we can run it > ourselves? Please find attached three files. The first is a 3rd party config module the software uses, the second is a patch to switch to a workable and failing runnable and the third is the small runnable that is showing the trouble. Running it is easy: $ tar zxf SoundOfMusic.tar.gz $ cd SoundOfMusic $ ./uistart.py The user interface should appear. First click on the Voice button on the right part of the screen. A voice button appears on the top part of the screen. Next press the Main button on the left top part of the screen. A segmentation fault is the result. Segmentation fault $ patch < ../SoundOfMusic.patch patching file ui_panel.py patching file ui_wx.py $ ./uistart.py Repeat the action and all works correctly. The patch removes my attempt to speed up some parts of the application by sort of like pre-loading all the panel data. Thanks in advance for any help! -- $ cat ~/.signature Freddy Spierenburg dusktilldawn.nl> http://freddy.snarl.nl/ GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1 E588 6F17 FD5D 7941 D1E1 $ # Please read http://www.ietf.org/rfc/rfc2015.txt before complain!
  Approximate file size 43370 bytes
  Approximate file size 2043 bytes
  Approximate file size 128556 bytes
Re: Segmentation fault while using SetSize()
country flaguser name
United States
2007-10-03 15:53:27
Freddy Spierenburg wrote:
> Hi Robin,
> 
> On Tue, Oct 02, 2007 at 12:41:56PM -0700, Robin Dunn
wrote:
>> So where is the SetSize that is causing the
trouble?
> 
> It's on line 262 of the file ui_wx.py. If you dive into
this the
> way I did, you will find out that the GetSize() works,
but the
> SetSize() causes the segmentation fault. See my
previous mail for
> further detail.
> 
> 
>> Can you make a small runnable sample that shows the
problem so we can run it 
>> ourselves?
> 
> Please find attached three files. The first is a 3rd
party config
> module the software uses, the second is a patch to
switch to a
> workable and failing runnable and the third is the
small runnable
> that is showing the trouble.


http://wiki
.wxpython.org/MakingSampleApps


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java
give you jitters?  Relax with wxPython!


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )