Author Topic: Crash @ Compile Current File  (Read 5257 times)

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Crash @ Compile Current File
« on: July 15, 2005, 11:56:41 pm »
Well, I just got it to test it and... lovely, lovely crash.

Program received signal SIGSEGV, Segmentation fault.
0x01e6cc2e in CompilerGCC::AddOutputLine (this=0x1d158b8, output=@0x22fa70,
    forceErrorColor=false) at plugins/compilergcc/compilergcc.cpp:1849
1849            CompilerLineType clt = compiler->CheckForWarningsAndErrors(output);

(gdb) bt
#0  0x01e6cc2e in CompilerGCC::AddOutputLine (this=0x1d06390,
    output=@0x22f9f8, forceErrorColor=false)
    at plugins/compilergcc/compilergcc.cpp:1849
#1  0x01e6c876 in CompilerGCC::OnGCCError (this=0x1d06390, event=@0x22bc018)
    at plugins/compilergcc/compilergcc.cpp:1829
#2  0x100a8ff8 in wxEvtHandler::ProcessEventIfMatches ()
   from E:\WINDOWS\system32\wxmsw26_gcc_custom.dll

 :cry:

[edit]
Ok, got something more that could maybe help:

(gdb) p clt
$1 = 2090035912
(gdb) p compiler
$2 = (class Compiler *) 0x2180738
(gdb) p output
$3 = (const wxString &) @0x22f9f8: {<wxStringBase> = {
    static npos = 4294967295,
    m_pchData = 0x22a3ec4 "mingw32-g++.exe: E:\\Documents: No such file or directory"}, <No data fields>}

That problem is because the compiler couldn't find the file 'cause its path has spaces.

Just tried with another file in the root of a drive and... crash!

(gdb) p output
$4 = (const wxString &) @0x22f9f8: {<wxStringBase> = {
    static npos = 4294967295,
    m_pchData = 0x22c2dec "D:\\port.o(.text+0x3a):port.c: undefined reference to `outportb'"}, <No data fields>}

So it's more like the plugin isn't handling the errors correctly and crashing because of them.

Changed the code of the program so it wouldn't have compile/link problems (just noticed it was an old DOS program) and it worked!
[/edit]

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Crash @ Compile Current File
« Reply #1 on: July 16, 2005, 12:55:02 am »
shall i make a project for you ? **GRIN**

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Crash @ Compile Current File
« Reply #2 on: July 16, 2005, 01:04:21 am »
wait, this is serious. Ceniza, can you post this at SF along with the file, so that we can reproduce it?

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Crash @ Compile Current File
« Reply #3 on: July 16, 2005, 02:40:12 am »
The file doesn't matter, as far as it have some compiler/linker problem or it be in a path with spaces.

You sure you want me to add
Code: [Select]
#include <dos.h>

int main()
{
  outportb(0x378, 1);
  return 0;
}


to SF?

It should say that dos.h doesn't exist and couldn't find outportb when linking.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Crash @ Compile Current File
« Reply #4 on: July 16, 2005, 10:48:20 am »
Quote from: Ceniza
The file doesn't matter, as far as it have some compiler/linker problem or it be in a path with spaces.

You sure you want me to add
Code: [Select]
#include <dos.h>

int main()
{
  outportb(0x378, 1);
  return 0;
}


to SF?

It should say that dos.h doesn't exist and couldn't find outportb when linking.


Your sample compiles fine with my old TurboC 2.01 dos-compiler  :)

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1442
    • CenizaSOFT
Crash @ Compile Current File
« Reply #5 on: July 16, 2005, 10:53:35 am »
Ok, for your consideration, quick fix which seems to be working:

plugins/compilergcc/compilergcc.cpp line 152 from:
Code: [Select]
   : m_CompilerIdx(-1),

to:
Code: [Select]
   : m_CompilerIdx(0),


I finally found the problem in there is the index never got updated so it tried to access an array at position -1.

Now, about the paths with spaces, I made this workaround (you're the ones who really know the code so it could be done somewhere else in a nicer way):

plugins/compilergcc/directcommands.cpp starting on line 269 from:
Code: [Select]
   wxString o_filename = fname.GetFullPath();
    fname.SetExt(EXECUTABLE_EXT);
    wxString exe_filename = fname.GetFullPath();

    MakefileGenerator mg(m_pCompilerPlugin, 0, "", 0); // don't worry! we just need a couple of utility funcs from it

    wxString compilerCmd = mg.CreateSingleFileCompileCmd(ctCompileObjectCmd,
                                                         0,
                                                         0,
                                                         filename,
                                                         o_filename,
                                                         wxEmptyString);

to:
Code: [Select]
   wxString o_filename = '"' + fname.GetFullPath() + '"';
    fname.SetExt(EXECUTABLE_EXT);
    wxString exe_filename = '"' + fname.GetFullPath() + '"';
    wxString i_filename = '"' + filename + '"';

    MakefileGenerator mg(m_pCompilerPlugin, 0, "", 0); // don't worry! we just need a couple of utility funcs from it

    wxString compilerCmd = mg.CreateSingleFileCompileCmd(ctCompileObjectCmd,
                                                         0,
                                                         0,
                                                         i_filename,
                                                         o_filename,
                                                         wxEmptyString);


plugins/compilergcc/makefilegenerator.cpp starting on line 218 from:
Code: [Select]
    wxFileName fname(object);

to:
Code: [Select]
    wxString object_unquoted(object);
    if (!object_unquoted.IsEmpty() && object_unquoted[0] == '"')
    {
    object_unquoted.Replace("\"", "");
    }
    wxFileName fname(object_unquoted);


I hope it be of any use.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Crash @ Compile Current File
« Reply #6 on: July 17, 2005, 06:33:06 pm »
Fixed in CVS. Thanks ceniza for pointing it out :)

Yiannis.
Be patient!
This bug will be fixed soon...