Author Topic: Ticket #108 App crashes when pressing F9 / compile+run  (Read 2081 times)

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11128
    • Travis build status
Ticket #108 App crashes when pressing F9 / compile+run
« on: December 10, 2014, 01:21:07 am »
Can someone try to reproduce the crash from ticket #108? https://sourceforge.net/p/codeblocks/tickets/108/
I've not tried it on linux, but I suppose it is windows only.
(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: 5085
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Ticket #108 App crashes when pressing F9 / compile+run
« Reply #1 on: December 10, 2014, 02:01:34 pm »
Can someone try to reproduce the crash from ticket #108? https://sourceforge.net/p/codeblocks/tickets/108/
I've not tried it on linux, but I suppose it is windows only.
I has problems to access to SF (SF was blocked by my country from time to time >:( )
So, I wrote here, I just see the backtrack from GDB
Code: [Select]
Program received signal SIGSEGV, Segmentation fault.
At F:\cb_sf_git\trunk\src\plugins\compilergcc\depslib\src\pathsplit.c:74

[debug]> bt 30
[debug]#0  0x64b51796 in path_split (path=0x0, f=0x22ecec) at F:\cb_sf_git\trunk\src\plugins\compilergcc\depslib\src\pathsplit.c:74
[debug]#1  0x64b514f7 in depsTimeStamp (path=0x0, time=0x22ef34) at F:\cb_sf_git\trunk\src\plugins\compilergcc\depslib\src\depslib.c:142
[debug]#2  0x64b50402 in DirectCommands::IsObjectOutdated (this=0x22f0c4, target=0x98f9028, pfd=..., errorStr=0x22ef9c) at F:\cb_sf_git\trunk\src\plugins\compilergcc\directcommands.cpp:1060
[debug]#3  0x64b4c931 in DirectCommands::GetTargetCompileCommands (this=0x22f0c4, target=0x98f9028, force=false) at F:\cb_sf_git\trunk\src\plugins\compilergcc\directcommands.cpp:488
[debug]#4  0x64b4c729 in DirectCommands::GetCompileCommands (this=0x22f0c4, target=0x98f9028, force=false) at F:\cb_sf_git\trunk\src\plugins\compilergcc\directcommands.cpp:450
[debug]#5  0x64b14ffd in CompilerGCC::BuildStateManagement (this=0x6da5a70) at F:\cb_sf_git\trunk\src\plugins\compilergcc\compilergcc.cpp:2395
[debug]#6  0x64b0f6d4 in CompilerGCC::DoRunQueue (this=0x6da5a70) at F:\cb_sf_git\trunk\src\plugins\compilergcc\compilergcc.cpp:1236
[debug]#7  0x64b16573 in CompilerGCC::DoBuild (this=0x6da5a70, target=<g_strEmpty+12> L"", clean=false, build=true, clearLog=true) at F:\cb_sf_git\trunk\src\plugins\compilergcc\compilergcc.cpp:2699
[debug]#8  0x64b165e9 in CompilerGCC::Build (this=0x6da5a70, target=<g_strEmpty+12> L"") at F:\cb_sf_git\trunk\src\plugins\compilergcc\compilergcc.cpp:2705
[debug]#9  0x64b16654 in CompilerGCC::Build (this=0x6da5a70, target=0x0) at F:\cb_sf_git\trunk\src\plugins\compilergcc\compilergcc.cpp:2710
[debug]#10 0x64b179b8 in CompilerGCC::OnCompile (this=0x6da5a70, event=...) at F:\cb_sf_git\trunk\src\plugins\compilergcc\compilergcc.cpp:2996
[debug]#11 0x64b0c216 in CompilerGCC::Dispatcher (this=0x6da5a70, event=...) at F:\cb_sf_git\trunk\src\plugins\compilergcc\compilergcc.cpp:639
[debug]#12 0x627015f1 in wxAppConsole::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#13 0x6276a07e in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#14 0x6276a14a in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#15 0x6276a545 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#16 0x6276a4d9 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#17 0x6276a4d9 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#18 0x6276a4d9 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#19 0x6276a4d9 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#20 0x6276a4d9 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#21 0x6276a4d9 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#22 0x6276a4d9 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#23 0x6276a4d9 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#24 0x6276a4d9 in wxEvtHandler::ProcessEvent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#25 0x6283f502 in wxWindowBase::TryParent(wxEvent&) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#26 0x62834bcf in wxToolBarBase::OnLeftClick(int, bool) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#27 0x627d5e0c in wxToolBar::MSWCommand(unsigned int, unsigned short) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#28 0x627b9d01 in wxFrame::HandleCommand(unsigned short, unsigned short, void*) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug]#29 0x627ba173 in wxFrame::MSWWindowProc(unsigned int, unsigned int, long) () from E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll\wxmsw28u_gcc_custom.dll
[debug](More stack frames follow...)
[debug]>>>>>>cb_gdb:


It is related to dependlib in the line:
Code: [Select]
void path_split(const char *path, PATHSPLIT *f)
{
const char *p = path;
#ifdef DEPSLIB_WINDOWS
// support UNC filename in windows: ignore leading slashes
while ((*p == '/') || (*p == '\\')) //******************* crash here***********************
        ++p;
#endif
PATHPART *part;

f->count = 1;
f->part[0].ptr = path;
Here, p is 0.
« Last Edit: December 10, 2014, 02:03:08 pm 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: 5085
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Ticket #108 App crashes when pressing F9 / compile+run
« Reply #2 on: December 10, 2014, 02:15:03 pm »
It looks like the special folder "testabcă"
Code: [Select]
source_file_absolute_native = L"D:\\temp\\testabc\003\001\\acb\\main.cpp"and then:
Code: [Select]
bool DirectCommands::IsObjectOutdated(ProjectBuildTarget* target, const pfDetails& pfd, wxString* errorStr) const
{
    // If the source file does not exist, then do not compile.
    time_t timeSrc;
    depsTimeStamp(pfd.source_file_absolute_native.mb_str(), &timeSrc);

But source_file_absolute_native.mb_str() failed and return a 0.
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: 5085
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Ticket #108 App crashes when pressing F9 / compile+run
« Reply #3 on: December 11, 2014, 05:11:14 am »
Code: [Select]
    wxString msg = wxT("abcă");
    const char *pppp = msg.mb_str();
On WinXP
Under wx2.8.12, I get the pppp value is 0.
Under wx3.0, I get pppp is not zero, but *pppp is 0.
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 BlueHazzard

  • Lives here!
  • ****
  • Posts: 2022
Re: Ticket #108 App crashes when pressing F9 / compile+run
« Reply #4 on: April 20, 2018, 12:40:32 am »
Still a problem with wx3.0.2 on win 7 64bit

interesting that a conversion from "internal" utf16 to "external" utf16 fails, but
Code: [Select]
wxString msg = wxT("abcă");
    const char *pppp = msg.ToUTF8();
is working like a charm....

Anyway: codeblocks should not crash if a conversation fails, so there should be a null check, because wxString::mb_str() can fail:
http://docs.wxwidgets.org/trunk/classwx_string.html
Quote
String in the current locale encoding implicitly or using c_str() or mb_str() methods. This is a potentially destructive operation as an empty string is returned if the conversion fails.

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 2022
Re: Ticket #108 App crashes when pressing F9 / compile+run
« Reply #5 on: April 21, 2018, 12:54:12 am »
i have the bad feeling, that this whole depslib is not unicode aware?
can someone explain to me what this depslib does?
Is it only timestamp reading ecc? Can't we do this in c++?
ok i got it. It searches for dependencies... What is the origin of this library?

i have googled for depslib but could not find anything...

[EDIT2:]
i just found out, that gcc also can not handle this kind of character:
Code: [Select]
G:\test>gcc -M tmp\ă\main.cpp
gcc: error: tmp\a\main.cpp: No such file or directory
gcc: fatal error: no input files
compilation terminated.

« Last Edit: April 21, 2018, 01:22:14 am by BlueHazzard »