ariba::utility::BlockingMethod

1 view
Skip to first unread message

omn...@mario.n-ten.de

unread,
Jul 30, 2011, 9:00:07 AM7/30/11
to SpoVNet
I followed the "Threading and the SystemQueue" Examples on the ariba
website for a proper threading solution, and tried to subclass
BlockingMethod in order to read from disc.

The problem is, even a minimal implementation always crashes on
"dispatch();" with the error message:
> pure virtual method called
> terminate called without an active exception
> Abgebrochen

In the ariba code I found this possible source of error:

source/ariba/utility/system:

BlockingMethod.h:
protected:
void handleSystemEvent(const SystemEvent& event);

but in it's superclass SystemEventListener.h:
public: // should be private, see comments in SystemEvent.h
virtual void handleSystemEvent( const SystemEvent& event ) = 0;

But changing both functions beeing either public or protected and
adding "virtual" in BlockingMethod.h didn't fix the problem.


-------------------------------------------------------------------------------------------------------------------

My code looks as follows:

#ifndef BLOCKING_BUFFER_H_
#define BLOCKING_BUFFER_H_

#include "ariba/utility/system/BlockingMethod.h"
using ariba::utility::BlockingMethod;

class Blocking_buffer : public BlockingMethod
{
public:
Blocking_buffer();
virtual ~Blocking_buffer();

void test_loop(Useroutputinterface* ui);

protected:
virtual void blockingFunction();
virtual void dispatchFunction();


private:
bool running;
int counter;
};

#endif /* BLOCKING_BUFFER_H_ */


----------------------------------------------

#include "Blocking_buffer.h"

Blocking_buffer::Blocking_buffer() : running(false), counter(0)
{
}

Blocking_buffer::~Blocking_buffer()
{
}

void Blocking_buffer::test_loop(Useroutputinterface* ui)
{
if ( ! running )
{
running = true;

cout << "BEFORE blocking function" << endl;
runBlockingMethod();
// blockingFunction();
cout << "AFTER blocking function" << endl;
}
}


/** BlockingMethod Inteface **/
void Blocking_buffer::blockingFunction()
{
sleep(5);
dispatch();
}

void Blocking_buffer::dispatchFunction()
{
cout << "DISPATCH function" << endl;
running = false;
}

It always crashes on "dispatch();".

I don't believe the bug is on my side and hope it can be investigated
soon.

Best regards, Mario

Christoph Mayer

unread,
Jul 30, 2011, 2:10:34 PM7/30/11
to SpoVNet
Hi, I integrated your exact code into the pingpong sample and it
worked perfectly. Are you actually compiling Blocking_buffer.cpp in
the Makefile.am? It rather seems to me that the pure virtual function
results from the fact that the object file of the class is not
compiled into the executable.

Chris

On 30 Jul., 15:00, "omni...@mario.n-ten.de" <omni...@mario.n-ten.de>
wrote:

omn...@mario.n-ten.de

unread,
Jul 31, 2011, 12:42:03 PM7/31/11
to SpoVNet
Hello Christoph, thank you for your quick reply.

Hm, I followed your example and also integrated the Blocking_buffer
into the Pingpong sample. But here I get the same errors. I also
double checked the Makefile.am ;-) The program makes it to:
> BEFORE blocking function
> AFTER blocking function

and then crashes with:
> pure virtual method called
> terminate called without an active exception
> Aborted

Could you please send me your pingpong folder as tar.gz (or
something), probably my fault lies somewhere I don't expect it...

On which compliler did you build it? I tried it under ubuntu 10.10 and
in the Contest-VM.
A bit strange is also that on ubuntu 10.10 it crashes after sleep(5)
on dispatch but in the VM it crashes just after "AFTER blocking
function".

Which version of ariba do you use? I have 0.7.0. What about the
missing "virtual" in BlockingMethod.h, does it run's on your machine
anyway?

Kind regards, Mario

omn...@mario.n-ten.de

unread,
Aug 1, 2011, 5:28:47 AM8/1/11
to SpoVNet
Hello Christoph,

thank you for your assistence. Your Pingpong code also works fine
here, with ariba-0.7.0.
I tracked down the problem that the crash always happens when creating
the Blocking_buffer on the stack. Afterwords not so surprising at all,
as the Blocking_buffer is destroyed before dispatch is invoked.. The
error messages of c++ sometimes can just be a little bit confusing.

Regards, Mario
Reply all
Reply to author
Forward
0 new messages