[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FW: Help! pure virtual function called : Aborted
From: |
Subodh Shakya |
Subject: |
FW: Help! pure virtual function called : Aborted |
Date: |
Fri, 31 Aug 2001 11:13:07 +0530 |
Sorry, I seem to have sent this mail to wrong address so it bounced back.
> ----------
> From: Subodh Shakya
> Sent: Friday, August 31, 2001 11:06 AM
> To: 'Mike James'
> Subject: RE: Help! pure virtual function called : Aborted
> Importance: High
>
> IS IT POSSIBLE THAT an EMPTY IMPLEMENTATION is removed by gcc?
> Hi friends
>
> Thanks for your effort to put my misery to end. I have been trying out
> with all these things myself. However I havent been able to find a pure
> virtual method that has not been implemented.
>
> Following is the code where the debugger throws up
> error ( at the commented pThis->Initial() method
>
> void* ACS_Thread::Thread_Function(void *lParam)
> {
> ACS_Thread *pThis = reinterpret_cast<ACS_Thread*>(lParam);
> try
> {
> //pThis->Initial();
> pThis->Run();
> pThis->Final();
> pThis->m_StopWaitEvent.Set();
> }catch(...)
> {
> ACS_Exception e;
> DebugTrace(e.getErrorCode(),e.getErrorMessage().c_str());
> throw(e);
> }
> ACS_ThreadManager::GetInstance()->UnRegisterThread(pThis);
> pthread_exit(0);
> return 0;
> }
>
> Ther Initial method for the derived class is as follows
> // Create's the interpreter and the new commands
> void ACS_TclInterp::Initial()
> {
> m_pTclInterp = Tcl_CreateInterp();
> RegisterTclCommands(m_pTclInterp);
> ACS_TaskPerformer::Initial();
> }
>
> And the one for the ACS_TaskPerformer is as follows
>
> void ACS_TaskPerformer::Initial()
> {
> #ifdef WIN32
> // HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
> // if (!SUCCEEDED(hr))
> // {
> // DebugTrace(eDebugTraceError,"Error intialising COM
> apratment %d",hr);
> // }
> #endif
> }
>
> IN CASE WIN32 IS NOT DEFINED, THE Initial() method contains an empty body.
> Is it possible that gcc is causing an optimization by removing this mehtod
> of the derived class and actually making the vtable entries to point to
> the constructor of the base class (which is pure virtual) during the
> reinterpret_cast?
>
> I suspect this happens at the following line
>
> ACS_Thread *pThis = reinterpret_cast<ACS_Thread*>(lParam);
>
>
> The definition for ACS_Thread.h is as follows
> class ACS_COMMON_API ACS_Thread
> {
> public:
> // constructor. this creates the thread in
> // suspended mode. so the Start or Resume function
> // must be called after the thread has been created.
> // That will activate the thread.
> ACS_Thread(const String& strThreadName="???");
>
> // this virutal function can be overridden to perform
> // the initialization stuffs
> virtual void Initial(void) { }
>
> // this virutal function can be overridden to perform
> // the cleanup stuffs
> virtual void Final(void) { }
>
> // This pure virual function must be overridden to
> // perform the thread operation
> virtual void Run(void) = 0;
>
> // Starts the thread thats created in suspened mode
> void Start(void);
>
> //shuts down the runnign thread
> virtual void ShutdownThread(void);
>
> // Resumes the suspended thread
> void Resume(void);
>
> // Suspends the running thread
> void Suspend(void);
>
> // destructor
> virtual ~ACS_Thread(void);
> //..... etc
> }
>
> Regards
> Subodh Shakya
>
>
> ----------
> From: Mike James[SMTP:mgwjames@ucalgary.ca]
> Sent: Thursday, August 30, 2001 8:46 PM
> To: Subodh Shakya
> Subject: Re: Help! pure virtual function called : Aborted
>
>
> Most likely you are inheriting a base class that has been declated to be
> pure virtual in one or more of its methods and you are not defining that
> method.
>
> Take a look at the class definitions and look for something that has been
> equated to 0. (ie. int myMethod() = 0).
> That is how a class becomes pure virtual. If you find something that
> looks
> like the declaration about you need to re-define it in your derived
> classes.
> The easiest thing to do in the derived class definition, if you are not
> using that method is the following (using the above example) is "int
> myMethod() {}".
>
> Hope that helps. Without the actual code it is difficult to give advice.
>
> Cheers..and good luck
> Mike
> ----- Original Message -----
> From: "Subodh Shakya" <SubodhS@PLANETASIA.COM>
> To: <help-gplusplus@gnu.org>
> Sent: Wednesday, August 29, 2001 11:15 PM
> Subject: Help! pure virtual function called : Aborted
>
>
> >
> > Hi
> >
> > My program runs well in Microsoft VC++ but on gcc3.0 / RedHat 7.1, the
> > program says pure virtual call and aborts execution. Can somebody help
> me
> > please?
> >
> >
> > Thanks in advance
> >
> > Regards
> >
> > Subodh Shakya
> >
> > _______________________________________________
> > Help-gplusplus mailing list
> > Help-gplusplus@gnu.org
> > http://mail.gnu.org/mailman/listinfo/help-gplusplus
> >
>
>