Author Topic: using code profiler in C - crash! (svn 7071)  (Read 10479 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13069
    • Travis build status
Re: using code profiler in C - crash! (svn 7071)
« Reply #15 on: March 30, 2011, 03:34:43 pm »
Pecan:
wxTreeItemId() and wxTreeItemId(0) should be equivalent, as far as I can see in the wxTreeItemId's code.
And the docs/header file say that the user is not allowed to call the latter.
The user may call only IsOk and probably to default construct an object.

See here for the source of wxTreeItemId: http://svn.wxwidgets.org/viewvc/wx/wxWidgets/branches/WX_2_8_BRANCH/include/wx/treebase.h?view=markup

Also look at the first post for the errors.
As you can see, the compiler sees two constructors:
wxTreeItemId(void*) and wxTreeItemId(long), this is ambiguous on 64bit machines, because sizeof(void*) == sizeof(long) and sizeof(int) != sizeof(long).
So id = 0, requires a cast and the compiler have two equally valid options.

Stahta01:
Why not? The binary wxGTK package for CentoOS 5.5  is compiled with this option and with my patch C::B works without problems.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7065
    • My Best Post
Re: using code profiler in C - crash! (svn 7071)
« Reply #16 on: March 30, 2011, 03:41:35 pm »
Code: [Select]
#if WXWIN_COMPATIBILITY_2_4
74 // deprecated: only for compatibility, don't work on 64 bit archs
75 wxTreeItemId(long item) { m_pItem = wxUIntToPtr(item); }
76 operator long() const { return (long)wxPtrToUInt(m_pItem); }
77 #else // !WXWIN_COMPATIBILITY_2_4

I can read and I am guessing the wx devs know what is right about their code.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13069
    • Travis build status
Re: using code profiler in C - crash! (svn 7071)
« Reply #17 on: March 30, 2011, 04:06:02 pm »
OK, And have you seen some lines above it that the only methods allowed are the default constructor
(it is not written as allowed, but I guess it is, I will write a bug report for it thought:) ) and the IsOk?
And wxTreeItemId(void *) is not one of them, so the C::B's usage is wrong (I'll contact wx guys to
hear what they think about it).

Can someone test my patch and verify that CodeSnippets is working with it. I don't use it and can't do so, unfortunately.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: using code profiler in C - crash! (svn 7071)
« Reply #18 on: March 30, 2011, 09:18:48 pm »
OK, And have you seen some lines above it that the only methods allowed are the default constructor
(it is not written as allowed, but I guess it is, I will write a bug report for it thought:) ) and the IsOk?
And wxTreeItemId(void *) is not one of them, so the C::B's usage is wrong (I'll contact wx guys to
hear what they think about it).

Can someone test my patch and verify that CodeSnippets is working with it. I don't use it and can't do so, unfortunately.
I don't use it also.

About the constructor:
Quote from: http://docs.wxwidgets.org/2.8/wx_wxtreeitemid.html#wxtreeitemidconstr
wxTreeItemId::wxTreeItemId

wxTreeItemId()

Default constructor. wxTreemItemIds are not meant to be constructed explicitly by the user; they are returned by the wxTreeCtrl functions instead.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13069
    • Travis build status
Re: using code profiler in C - crash! (svn 7071)
« Reply #19 on: March 30, 2011, 09:37:22 pm »
Jens you are correct, here is the explanation from the #wxwidgets in irc.freenode.com

Quote
(2011-03-30 22:25:13) obfuscated: hi, can I do something like "class Something { wxTreeItemId storeForLater; }; " or this is not allowed?
(2011-03-30 22:26:46) DavidGH: obfuscated: You can't reliably do that, as a wxTreeItemId isn't guaranteed to live for long
(2011-03-30 22:27:13) DavidGH: As soon as a tree is recreated, or (I think) an item inserted, the old ids become invalid
(2011-03-30 22:27:36) obfuscated: so, how do you store something like a pointer to an item?
(2011-03-30 22:28:05) DavidGH: You don't. You search the tree each time you want it
(2011-03-30 22:28:52) DavidGH: Of course it depends on your situation: if you are certain that the tree won't be altered in the course of your function...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: using code profiler in C - crash! (svn 7071)
« Reply #20 on: March 31, 2011, 12:22:55 pm »
Dear oBFusCATed,

Sorry for my late test report. I'm a little bit busy these days. :)

I've reinstalled the Fedora official wxGTK-2.8.11-3  (official Fedora releasw wxGTK has "--enable-compat24 \" in its rpm .spec file ). Then I re-combined the codeblocks-svn7074 with your patch.

I got errors, please view as follows:
Quote

---------------
......
......
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../../../src/include -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I../../../../src/include -I../../../../src/sdk/wxscintilla/include -I../../../../src/plugins/contrib/codesnippets -I../../../../src/plugins/contrib/codesnippets/Search -I../../../../src/plugins/contrib/codesnippets/editor -I../../../../src/include/mozilla_chardet -Ulinux -Uunix -O2 -ffast-math -DCB_AUTOCONF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -c Search/DirectoryParamsPanel.cpp  -fPIC -DPIC -o .libs/DirectoryParamsPanel.o
/bin/sh ../../../../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../../../src/include -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12    -I../../../../src/include -I../../../../src/sdk/wxscintilla/include -I../../../../src/plugins/contrib/codesnippets -I../../../../src/plugins/contrib/codesnippets/Search -I../../../../src/plugins/contrib/codesnippets/editor -I../../../../src/include/mozilla_chardet  -Ulinux -Uunix  -O2 -ffast-math -DCB_AUTOCONF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -c -o InsertIndexManager.lo `test -f 'Search/InsertIndexManager.cpp' || echo './'`Search/InsertIndexManager.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../../../src/include -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I../../../../src/include -I../../../../src/sdk/wxscintilla/include -I../../../../src/plugins/contrib/codesnippets -I../../../../src/plugins/contrib/codesnippets/Search -I../../../../src/plugins/contrib/codesnippets/editor -I../../../../src/include/mozilla_chardet -Ulinux -Uunix -O2 -ffast-math -DCB_AUTOCONF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -c Search/InsertIndexManager.cpp  -fPIC -DPIC -o .libs/InsertIndexManager.o
codesnippets.cpp: In constructor 'CodeSnippets::CodeSnippets()':
codesnippets.cpp:109:52: error: conversion from 'int' to 'const wxTreeItemId' is ambiguous
/usr/include/wx-2.8/wx/treebase.h:75:5: note: candidates are: wxTreeItemId::wxTreeItemId(long int)
/usr/include/wx-2.8/wx/treebase.h:59:5: note:                 wxTreeItemId::wxTreeItemId(void*)
codesnippets.cpp: In member function 'void CodeSnippets::OnPrjTreeMouseLeftDownEvent(wxMouseEvent&)':
codesnippets.cpp:1243:30: error: conversion from 'int' to 'const wxTreeItemId' is ambiguous
/usr/include/wx-2.8/wx/treebase.h:75:5: note: candidates are: wxTreeItemId::wxTreeItemId(long int)
/usr/include/wx-2.8/wx/treebase.h:59:5: note:                 wxTreeItemId::wxTreeItemId(void*)
codesnippets.cpp:1244:28: error: conversion from 'int' to 'const wxTreeItemId' is ambiguous
/usr/include/wx-2.8/wx/treebase.h:75:5: note: candidates are: wxTreeItemId::wxTreeItemId(long int)
/usr/include/wx-2.8/wx/treebase.h:59:5: note:                 wxTreeItemId::wxTreeItemId(void*)
codesnippets.cpp: In member function 'void CodeSnippets::OnPrjTreeMouseLeftUpEvent(wxMouseEvent&)':
codesnippets.cpp:1273:28: error: conversion from 'int' to 'const wxTreeItemId' is ambiguous
/usr/include/wx-2.8/wx/treebase.h:75:5: note: candidates are: wxTreeItemId::wxTreeItemId(long int)
/usr/include/wx-2.8/wx/treebase.h:59:5: note:                 wxTreeItemId::wxTreeItemId(void*)
codesnippets.cpp: In member function 'void CodeSnippets::DoPrjTreeExternalDrag(wxTreeCtrl*)':
codesnippets.cpp:1449:30: error: conversion from 'int' to 'const wxTreeItemId' is ambiguous
/usr/include/wx-2.8/wx/treebase.h:75:5: note: candidates are: wxTreeItemId::wxTreeItemId(long int)
/usr/include/wx-2.8/wx/treebase.h:59:5: note:                 wxTreeItemId::wxTreeItemId(void*)
codesnippets.cpp:1450:28: error: conversion from 'int' to 'const wxTreeItemId' is ambiguous
/usr/include/wx-2.8/wx/treebase.h:75:5: note: candidates are: wxTreeItemId::wxTreeItemId(long int)
/usr/include/wx-2.8/wx/treebase.h:59:5: note:                 wxTreeItemId::wxTreeItemId(void*)
make[5]: *** [codesnippets.lo] Error 1
make[5]: *** Waiting for unfinished jobs....
Search/InsertIndexManager.cpp: In member function 'long int InsertIndexManager::GetInsertionIndex(const wxString&, long int)':
Search/InsertIndexManager.cpp:24:7: warning: 'index' may be used uninitialized in this function
make[5]: Leaving directory `/home/David/rpmbuild/BUILD/codeblocks/src/plugins/contrib/codesnippets'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/David/rpmbuild/BUILD/codeblocks/src/plugins/contrib/codesnippets'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/David/rpmbuild/BUILD/codeblocks/src/plugins/contrib'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/David/rpmbuild/BUILD/codeblocks/src/plugins'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/David/rpmbuild/BUILD/codeblocks/src'
make: *** [all-recursive] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.lzgOx1 (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.lzgOx1 (%build)
[[email protected] SPECS]$



[[email protected] SPECS]$ rpm -qa | grep wx
wxGTK-gl-2.8.11-3.fc14.x86_64
wxBase-2.8.11-3.fc14.x86_64
wxGTK-2.8.11-3.fc14.x86_64
wxGTK-devel-2.8.11-3.fc14.x86_64
wxGTK-media-2.8.11-3.fc14.x86_64


[[email protected] SPECS]$ uname -a
Linux Ocean 2.6.35.11-83.fc14.x86_64 #1 SMP Mon Feb 7 07:06:44 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] SPECS]$
--------------

Temporarily solution:

1).
Just as stahta01 (Tim S) has told me before (http://forums.codeblocks.org/index.php/topic,14289.msg96177.html#msg96177).
Quote
Try building wxWidgets without using "--enable-compat24"
.
This can solve the Fedora official wxGTK2.8.11-3 conflicts with CodeBlocks-svn7047 problem.

or

2).
Re-build wxGTK using the official released wxWidgets2.8.12 source; then install corresponding produced wxGTK and wxBase files; then re-build CodeBlocks-svn7047.


Best regards.
David.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13069
    • Travis build status
Re: using code profiler in C - crash! (svn 7071)
« Reply #21 on: March 31, 2011, 12:27:20 pm »
Are you sure the patch have been applied?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: using code profiler in C - crash! (svn 7071)
« Reply #22 on: March 31, 2011, 01:48:38 pm »
Yes, I'm sure.

Maybe you do not want to see this; but I did patched acc. to your patch file, and I got errors during compiling.
« Last Edit: March 31, 2011, 01:52:36 pm by wangdong1226 »