Please help me back on the track!

Peter Thorstenson swede at tech-center.com
Sat Feb 26 17:55:48 GMT 2000


Hi!

I don't know if this is the prober place to post this.
I'm learning C++ and have been using kdevelop since 2 months.
My application for KDE 1.X is getting along over my expectations. That means
good.
However, five days ago I ran in to a problem that does not let me continue.
When the proble occured I ran kdevelop 1.0 so I changed it to 1.2beta2
but with no change.
To me it seems like a basic problem probably due to lak of knowelage from my
side.
Any help is appreciated.

Problem description:
A added a new class to my project: "mp3_header". In this class I declare a
variable "cat" as public. To me this means that any other class should be
able to set or alter the value of this variable. In this function it should
be enough to declare it as private I think.
BUT if I try to alter the value from a menu-slott bu calling "setCat()" as
follows, the program
quits directly with error:

Program received SIGSEGV, Segmentation fault.

In the prog.h file:
  #include <mp3_header.h>
:
:
  private:
  mp3_header *header;

In the prog.cpp file:
  //The command I put cleanly in a menu-slot
  header->setCat();

The functions I make in this class works fine. As long as I do not use any
variables declared outside the functions. Well it's not only this class it's
any class I add that works like this.
The program compiles fine. No complaints about missing declarations or
anything.
To me it seems as the declaration of the variable doesn't work. I must be
missing something very important!

I've been struggling for five days now trying to solve it but without luck.
PLEASE help me back on the track!

Regards,

Peter Torstenson
Rio de Janeiro, 35 degrees Celcius....

OK here's the info:

The class I added:
**** mp3_header.h *******************
#ifndef MP3_HEADER_H
#define MP3_HEADER_H

class mp3_header {
public:
  mp3_header();
  ~mp3_header();
  int cat;
  void setCat();
};

#endif


**** mp3_header.cpp ******************
#include "mp3_header.h"
#include <iostream.h>

mp3_header::mp3_header(){
}
mp3_header::~mp3_header(){
}
void mp3_header::setCat(){
  cat=2;  //This is where it stops!!
          // Saying: Program received SIGSEGV, Segmentation fault.

}
****************************************
Debug info:

MEMORY:
0x0: Cannot access memory at address 0x0.

DISASSEMBLER:
Dump of assembler code for function setCat__10mp3_header:
0x804c970 <setCat__10mp3_header>: push   %ebp
0x804c971 <setCat__10mp3_header+1>: mov    %esp,%ebp
0x804c973 <setCat__10mp3_header+3>: push   %ebx
0x804c974 <setCat__10mp3_header+4>: mov    0x8(%ebp),%ebx
0x804c977 <setCat__10mp3_header+7>: movl   $0x2,(%ebx)
0x804c97d <setCat__10mp3_header+13>: push   $0x805bf08
0x804c982 <setCat__10mp3_header+18>: push   $0x805bf0a
0x804c987 <setCat__10mp3_header+23>: push   $0x8064f38
0x804c98c <setCat__10mp3_header+28>: call   0x804c008 <__ls__7ostreamPCc>
0x804c991 <setCat__10mp3_header+33>: add    $0x8,%esp
0x804c994 <setCat__10mp3_header+36>: mov    %eax,%eax
0x804c996 <setCat__10mp3_header+38>: push   %eax
0x804c997 <setCat__10mp3_header+39>: call   0x804c008 <__ls__7ostreamPCc>
0x804c99c <setCat__10mp3_header+44>: add    $0x8,%esp
0x804c99f <setCat__10mp3_header+47>: mov    0xfffffffc(%ebp),%ebx
0x804c9a2 <setCat__10mp3_header+50>: mov    %ebp,%esp
0x804c9a4 <setCat__10mp3_header+52>: pop    %ebp
0x804c9a5 <setCat__10mp3_header+53>: ret
End of assembler dump.

REGISTERS:
eax            0x0 0
ecx            0x8084800 134760448
edx            0x805f001 134606849
ebx            0x0 0
esp            0x7ffffa3c 0x7ffffa3c
ebp            0x7ffffa40 0x7ffffa40
esi            0x7ffffa94 2147482260
edi            0x1 1
eip            0x804c977 0x804c977
eflags         0x10212 66066
cs             0x23 35
ss             0x2b 43
ds             0x2b 43
es             0x2b 43
fs             0x0 0
gs             0x0 0

LIBRARIES:
>From        To          Syms Read   Shared Object Library
0x2aac1000  0x2ab15dcc  Yes         /usr/lib/libkfile.so.2
0x2ab16000  0x2ab25cf0  Yes         /usr/lib/libkfm.so.2
0x2ab26000  0x2ac2ebe0  Yes         /usr/lib/libkdeui.so.2
0x2ac2f000  0x2acdcaac  Yes         /usr/lib/libkdecore.so.2
0x2acdd000  0x2aeee1c0  Yes         /usr/lib/libqt.so.1
0x2aeef000  0x2aefb980  Yes         /usr/X11R6/lib/libXext.so.6
0x2aefd000  0x2afabf88  Yes         /usr/X11R6/lib/libX11.so.6
0x2afac000  0x2aff1e30  Yes         /usr/lib/libstdc++.so.2.9
0x2affa000  0x2b017f08  Yes         /lib/libm.so.6
0x2b018000  0x2b11269c  Yes         /lib/libc.so.6
0x2aaab000  0x2aabf9b0  Yes         /lib/ld-linux.so.2










More information about the KDevelop mailing list