Author Topic: SVN build crashes when trying to editing/adding new compiler flags  (Read 28869 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12090
    • Travis build status
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #60 on: June 09, 2016, 08:34:18 pm »
I see you guys are busying fixing the issue. I want to make a suggestion. It may save much time by comparing changes regarding the dialog invoking code between the 16.01 release and current HEAD version to see what causes the crash.
There are none. I've done this already.
This is pure compiler problem or bug exposed by the compiler.
(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 BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2553
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #61 on: June 09, 2016, 10:29:44 pm »
it could also be some strange race condition...
but impossible (or at least very hard) to debug...

i can confirm the non existence of the bug with the debug build (wx2.8, tdm 5.1)
thx @stahta01 for the hint with the  __WXDEBUG__ flag

-O0 gives crash (only codeblocks)
-O1 gives crash (only codeblocks)
-O2 gives also crash

so i think the race condition is in wxWidgets dll?

greetings

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12090
    • Travis build status
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #62 on: June 10, 2016, 12:18:36 am »
I doubt it is a race condition, most probably it is some memory error or miscompilation.
(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 ssawgift

  • Multiple posting newcomer
  • *
  • Posts: 67
    • My personal website
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #63 on: June 10, 2016, 03:54:55 am »
I see you guys are busying fixing the issue. I want to make a suggestion. It may save much time by comparing changes regarding the dialog invoking code between the 16.01 release and current HEAD version to see what causes the crash.
There are none. I've done this already.
This is pure compiler problem or bug exposed by the compiler.

That's strange. Did you try the 16.01 release code? I think it must be some changes that causes the crash.

I see the crash occurs in CompilerFlagDlg.cpp at line 16:
wxXmlResource::Get()->LoadObject(this, parent, wxT("CompilerFlagDlg"), wxT("wxDialog"));

Is it that some changes in external XML resources broke something?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #64 on: June 11, 2016, 02:41:09 pm »
Is it that some changes in external XML resources broke something?
I don't think the changes in the XRC file cause this issue. (There is very tiny changes though)

The solution could be:
1, can we drop the wx 2.8.x support?
2, we can use an old gcc(such as tdm gcc 4.9.x)

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #65 on: June 26, 2016, 02:03:00 am »
I build wx 2.8.12 library with the -g option under tdm gcc 5.1, and get the crash call stack:
Code: [Select]
#0  0x6d11b345 in wxClassInfo::IsKindOf (info=0x6d283ac8 <wxScrolledWindow::ms_classInfo>, this=<optimized out>) at F:\wx\wxMSW-2.8.12\include\wx\object.h:94
#1  wxCheckDynamicCast (obj=0x22e520, classInfo=0x6d283ac8 <wxScrolledWindow::ms_classInfo>) at F:\wx\wxMSW-2.8.12\include\wx\object.h:502
#2  0x6cf9cf5d in wxSizerXmlHandler::Handle_sizer (this=<optimized out>) at F:\wx\wxMSW-2.8.12\src\xrc\xh_sizer.cpp:243
#3  0x6cfba8aa in wxXmlResourceHandler::CreateResource ([email protected]=0x1e42a00, node=0x3ada758, parent=0x22e520, instance=0x0) at F:\wx\wxMSW-2.8.12\src\xrc\xmlres.cpp:799
#4  0x6cfbf635 in wxXmlResource::CreateResFromNode (this=<optimized out>, node=0x3ada758, parent=0x22e520, instance=0x0, handlerToUse=0x0) at F:\wx\wxMSW-2.8.12\src\xrc\xmlres.cpp:709
#5  0x6cfc0641 in wxXmlResourceHandler::CreateChildren (this=<optimized out>, parent=0x22e520, this_hnd_only=false) at F:\wx\wxMSW-2.8.12\src\xrc\xmlres.cpp:1519
#6  0x6cf7673e in wxDialogXmlHandler::DoCreateResource (this=<optimized out>) at F:\wx\wxMSW-2.8.12\src\xrc\xh_dlg.cpp:80
#7  0x6cfba8aa in wxXmlResourceHandler::CreateResource ([email protected]=0x1e412c0, node=0x3acaeb8, parent=0x0, instance=0x22e520) at F:\wx\wxMSW-2.8.12\src\xrc\xmlres.cpp:799
#8  0x6cfbf635 in wxXmlResource::CreateResFromNode ([email protected]=0x1e3f068, node=0x3acaeb8, [email protected]=0x0, [email protected]=0x22e520, [email protected]=0x0) at F:\wx\wxMSW-2.8.12\src\xrc\xmlres.cpp:709
#9  0x6cfc04c7 in wxXmlResource::LoadObject (this=0x1e3f068, instance=0x22e520, parent=0x0, name=L"CompilerFlagDlg", classname=L"wxDialog") at F:\wx\wxMSW-2.8.12\src\xrc\xmlres.cpp:335
#10 0x64b08bfc in CompilerFlagDlg::CompilerFlagDlg (this=0x22e520, parent=0x0, opt=0x22e4fc, categ=wxArray<T> = {...}, selectedCategory=L"General") at F:\cb_sf_git\trunk\src\plugins\compilergcc\compilerflagdlg.cpp:16
#11 0x64b5a12a in CompilerOptionsDlg::OnFlagsPopup (this=0x3f2b3c8, event=...) at F:\cb_sf_git\trunk\src\plugins\compilergcc\compileroptionsdlg.cpp:3028
#12 0x6cc41272 in wxAppConsole::HandleEvent (this=<optimized out>, handler=0x3f2b3c8, func=<optimized out>, event=...) at F:\wx\wxMSW-2.8.12\src\common\appbase.cpp:322
#13 0x6cce0cb4 in wxEvtHandler::ProcessEventIfMatches (entry=..., handler=0x3f2b3c8, event=...) at F:\wx\wxMSW-2.8.12\src\common\event.cpp:1239
#14 0x6cce0d6a in wxEventHashTable::HandleEvent (this=<optimized out>, event=..., [email protected]=0x3f2b3c8) at F:\wx\wxMSW-2.8.12\src\common\event.cpp:906
#15 0x6cce1155 in wxEvtHandler::ProcessEvent (this=0x3f2b3c8, event=...) at F:\wx\wxMSW-2.8.12\src\common\event.cpp:1301
#16 0x6ce5e288 in wxWindowBase::TryParent (this=0x3f48998, event=...) at F:\wx\wxMSW-2.8.12\src\common\wincmn.cpp:2661
#17 0x6ce5e288 in wxWindowBase::TryParent (this=0x3f40ce0, event=...) at F:\wx\wxMSW-2.8.12\src\common\wincmn.cpp:2661
#18 0x6ce5e288 in wxWindowBase::TryParent (this=0x3f42158, event=...) at F:\wx\wxMSW-2.8.12\src\common\wincmn.cpp:2661
#19 0x6ce5e288 in wxWindowBase::TryParent (this=0x3f424f0, event=...) at F:\wx\wxMSW-2.8.12\src\common\wincmn.cpp:2661
#20 0x6ce5e288 in wxWindowBase::TryParent (this=0x3f28848, event=...) at F:\wx\wxMSW-2.8.12\src\common\wincmn.cpp:2661
#21 0x6ce5e288 in wxWindowBase::TryParent (this=0x3f81b68, event=...) at F:\wx\wxMSW-2.8.12\src\common\wincmn.cpp:2661
#22 0x014ab768 in wxPropertyGrid::ProcessEvent (this=0x3f81b68, event=...) at F:\cb_sf_git\trunk\src\sdk\wxpropgrid\src\propgrid.cpp:6982
#23 0x6cce10ea in wxEvtHandler::ProcessEvent (this=0x3f2b5e0, event=...) at F:\wx\wxMSW-2.8.12\src\common\event.cpp:1308
#24 0x6ce8b8cb in wxScrollHelperEvtHandler::ProcessEvent (this=0x3f2b5e0, event=...) at F:\wx\wxMSW-2.8.12\src\generic\scrlwing.cpp:208
#25 0x014ae824 in wxPropertyGrid::SendEvent (this=0x3f81b68, eventType=10437, p=0x3f852e8, pValue=0x0, selFlags=8, column=1) at F:\cb_sf_git\trunk\src\sdk\wxpropgrid\src\propgrid.cpp:8110
#26 0x014aefe7 in wxPropertyGrid::HandleMouseRightClick (this=0x3f81b68, event=...) at F:\cb_sf_git\trunk\src\sdk\wxpropgrid\src\propgrid.cpp:8294
#27 0x014afd7a in wxPropertyGrid::OnMouseRightClick (this=0x3f81b68, event=...) at F:\cb_sf_git\trunk\src\sdk\wxpropgrid\src\propgrid.cpp:8703
#28 0x014eb8e2 in wxPGCanvas::OnMouseRightClick (this=0x3f83068, event=...) at F:\cb_sf_git\trunk\src\sdk\wxpropgrid\src\propgrid.cpp:2984
#29 0x6cc41272 in wxAppConsole::HandleEvent (this=<optimized out>, handler=0x3f83068, func=<optimized out>, event=...) at F:\wx\wxMSW-2.8.12\src\common\appbase.cpp:322
#30 0x6cce0cb4 in wxEvtHandler::ProcessEventIfMatches (entry=..., handler=0x3f83068, event=...) at F:\wx\wxMSW-2.8.12\src\common\event.cpp:1239
#31 0x6cce0d6a in wxEventHashTable::HandleEvent (this=<optimized out>, event=..., [email protected]=0x3f83068) at F:\wx\wxMSW-2.8.12\src\common\event.cpp:906
#32 0x6cce1155 in wxEvtHandler::ProcessEvent (this=0x3f83068, event=...) at F:\wx\wxMSW-2.8.12\src\common\event.cpp:1301
#33 0x6cd4862f in wxWindow::HandleMouseEvent ([email protected]=0x3f83068, msg=517, x=142, y=79, flags=0) at F:\wx\wxMSW-2.8.12\src\msw\window.cpp:5172
#34 0x6cd4bd67 in wxWindow::MSWWindowProc (this=0x3f83068, message=517, wParam=0, lParam=5177486) at F:\wx\wxMSW-2.8.12\src\msw\window.cpp:2884
#35 0x6cd45816 in wxWndProc(HWND__*, unsigned int, unsigned int, long)@16 (hWnd=0x20ef0, message=517, wParam=0, lParam=5177486) at F:\wx\wxMSW-2.8.12\src\msw\window.cpp:2618
#36 0x7e418734 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
#37 0x00020ef0 in ?? ()
#38 0x7e418816 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
#39 0x6cd457b0 in wxWindow::AssociateHandle(void*) () at F:\wx\wxMSW-2.8.12\src\msw\window.cpp:1205
#40 0x7e4189cd in USER32!GetWindowLongW () from C:\WINDOWS\system32\user32.dll
#41 0x00000000 in ?? ()

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #66 on: June 26, 2016, 02:29:49 am »
When I'm on the line:
Code: C++
  1. inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
  2. {
  3.     return obj && obj->GetClassInfo()->IsKindOf(classInfo) ? obj : NULL;
  4. }
At the line 3, I see this from GDB:
Code: [Select]
> p obj

[debug]> p obj
[debug]$5 = (wxObject *) 0x22e520
[debug]>>>>>>cb_gdb:

$5 = (wxObject *) 0x22e520
> p obj->GetClassInfo()

[debug]> p obj->GetClassInfo()
[debug]$6 = (wxClassInfo *) 0x6d260098 <wxDialog::ms_classInfo>
[debug]>>>>>>cb_gdb:

$6 = (wxClassInfo *) 0x6d260098 <wxDialog::ms_classInfo>
But when I go to the calling function:

Code: C++
  1. class WXDLLIMPEXP_BASE wxClassInfo
  2. {
  3. public:
  4.     wxClassInfo( const wxChar *className,
  5.                  const wxClassInfo *baseInfo1,
  6.                  const wxClassInfo *baseInfo2,
  7.                  int size,
  8.                  wxObjectConstructorFn ctor )
  9.         : m_className(className)
  10.         , m_objectSize(size)
  11.         , m_objectConstructor(ctor)
  12.         , m_baseInfo1(baseInfo1)
  13.         , m_baseInfo2(baseInfo2)
  14.         , m_next(sm_first)
  15.         {
  16.             sm_first = this;
  17.             Register();
  18.         }
  19.  
  20.     ~wxClassInfo();
  21.  
  22.     wxObject *CreateObject() const
  23.         { return m_objectConstructor ? (*m_objectConstructor)() : 0; }
  24.     bool IsDynamic() const { return (NULL != m_objectConstructor); }
  25.  
  26.     const wxChar       *GetClassName() const { return m_className; }
  27.     const wxChar       *GetBaseClassName1() const
  28.         { return m_baseInfo1 ? m_baseInfo1->GetClassName() : NULL; }
  29.     const wxChar       *GetBaseClassName2() const
  30.         { return m_baseInfo2 ? m_baseInfo2->GetClassName() : NULL; }
  31.     const wxClassInfo  *GetBaseClass1() const { return m_baseInfo1; }
  32.     const wxClassInfo  *GetBaseClass2() const { return m_baseInfo2; }
  33.     int                 GetSize() const { return m_objectSize; }
  34.  
  35.     wxObjectConstructorFn      GetConstructor() const
  36.         { return m_objectConstructor; }
  37.     static const wxClassInfo  *GetFirst() { return sm_first; }
  38.     const wxClassInfo         *GetNext() const { return m_next; }
  39.     static wxClassInfo        *FindClass(const wxChar *className);
  40.  
  41.         // Climb upwards through inheritance hierarchy.
  42.         // Dual inheritance is catered for.
  43.  
  44.     bool IsKindOf(const wxClassInfo *info) const
  45.     {
  46.         return info != 0 &&
  47.                ( info == this ||
  48.                  ( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) ||
  49.                  ( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) );
  50.     }
  51.  

   
At the line 49, from GDB, I get:
Code: [Select]
> p this

[debug]> p this
[debug]$7 = (const wxClassInfo * const) 0x0
[debug]>>>>>>cb_gdb:

$7 = (const wxClassInfo * const) 0x0
> p m_baseInfo1

[debug]> p m_baseInfo1
[debug]Cannot access memory at address 0xc
[debug]>>>>>>cb_gdb:

Cannot access memory at address 0xc
> p m_baseInfo2

[debug]> p m_baseInfo2
[debug]Cannot access memory at address 0x10
[debug]>>>>>>cb_gdb:

Cannot access memory at address 0x10


So, it looks like the m_baseInfo2 is wrong here, right?

EDIT:
It looks like the m_baseInfo2 is a embedded struct of wxClassInfo, while wxClassInfo is an embedded struct of any wxObject, in it's static field, so maybe, the optimization of GCC get wrong? Or the function get wrong address of the embedded member address?
« Last Edit: June 26, 2016, 02:35:45 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #67 on: June 26, 2016, 02:43:29 am »
Another thing is that why we get a ZERO this pointer here? (in my previous post)
Code: [Select]
[debug]> p this
[debug]$7 = (const wxClassInfo * const) 0x0

But previously, we get a correct pointer:
Code: [Select]
[debug]> p obj->GetClassInfo()
[debug]$6 = (wxClassInfo *) 0x6d260098 <wxDialog::ms_classInfo>
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #68 on: June 26, 2016, 09:48:30 am »
I comfirm it is a GCC optimization error under Windows. (I just test TDM GCC 5.1)
I have take some time to debug the crash call stack, but I have no success.
Then, I have use the "-O0 -g" c++ compiler option to build a wx 2.8.12 library in another place, then under C::B, I just change the wx global variable to point to the new wx library location.

Then, I just start C::B inside C::B, and it works fine without crash. Note that I even did not rebuild C::B against the new build wx library.

The command line I use to build the new wx library is here:
Code: [Select]
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-Wno-unused-local-typedefs -Wno-deprecated-declarations -fno-keep-inline-dllexport -O0 -g" >log-debug.txt 2>&1

So, guys, I think we need to supply a -O0 build of the wx release library.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #69 on: June 26, 2016, 10:16:41 am »
By the way, I see some similar GCC issue half years ago, see this post and related discussion Re: Build C::B against wx3.02 with gcc 5.2 under Windows.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12090
    • Travis build status
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #70 on: June 26, 2016, 10:23:44 am »
Can you try newer mingw 5.x releases?
Can you try if the same thing happens with wx3.x?
Probably you can try to disable the optimizations for a single function?

@killerbot: Probably it is a good idea to revert the compiler to 4.9 for now.
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #71 on: June 26, 2016, 10:35:18 am »
Can you try newer mingw 5.x releases?
Some guys in this thread said that it also crashed under MinGW-Build GCC 5.3.

Quote
Can you try if the same thing happens with wx3.x?
It works fine under wx 3.x.
EDIT: Oh, I have debug versoin of wx trunk library for months, because release version (-O2) of wx trunk library build from GCC 5.3 also has some crash issues.

Quote
Probably you can try to disable the optimizations for a single function?
That need to change code in wx 2.8.12, and need a lot of trials. Very hard.

Quote
@killerbot: Probably it is a good idea to revert the compiler to 4.9 for now.
Agree, either revert to tdm gcc 4.9 or use a -O0 build of tdm gcc 5.1.
« Last Edit: June 26, 2016, 10:46:18 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline raynebc

  • Almost regular
  • **
  • Posts: 212
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #72 on: June 26, 2016, 10:51:35 am »
I don't suppose the -fno-delete-null-pointer-checks compiler flag disables the offending optimization in this case does it?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5241
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #73 on: June 29, 2016, 06:26:25 am »
I don't suppose the -fno-delete-null-pointer-checks compiler flag disables the offending optimization in this case does it?
GCC online documentation - GNU Project - Free Software Foundation (FSF), I read the document for gcc 4.9 and 5.4, but I see the "delete-null-pointer-checks" exits in both GCC versions.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline raynebc

  • Almost regular
  • **
  • Posts: 212
Re: SVN build crashes when trying to editing/adding new compiler flags
« Reply #74 on: June 29, 2016, 07:33:33 am »
That optimization is why I haven't updated beyond GCC 4.8.x, it was pretty well known as a disruptive change from what I understand.