public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Jesper Skov <jskov@cygnus.co.uk>
To: <bob.koninckx@mail.mech.kuleuven.ac.be>
Cc: ecos-discuss@sourceware.cygnus.com
Subject: [ECOS] Re: Some weirdnes with the tools
Date: Mon, 18 Oct 1999 05:14:00 -0000	[thread overview]
Message-ID: <14347.3841.654535.829791@thinktwice.zoftcorp.dk> (raw)
In-Reply-To: <000501bf195d$2c576080$56183a86@pc086-2.mech.kuleuven.ac.be>

If I'm not mistaken (and I may very well be) the problem is caused
because you use a 'new' operator without defining it. I think it calls
malloc() and throws an exception if the allocation fails. Remember
that C++ exceptions are not handled when you use the default compiler
arguments. 

Anyway, this is beyond me. I'm not the biggest C++ hacker there ever
was, I must admit. You should have asked on the list directly where
you would be more likely to get a correct answer.


Jesper

--------------------
Hi Jesper,
This WE, I came accross something I really do not understand. I am working
on a package implementing the CANopen protocol. I am writing this in C++.

It contains something like this :

class CommunicationObject
{ ...
  public:
    virtual      ~CommunicationObject();
    virtual void create(void) = 0;
    virtual void destroy(void) = 0;
};

class TxCOB : public CommunicationObject
{ ...
  public:
    virtual      ~TxCOB();
    virtual void create(void);
    virtual void destroy(void);
};

class RxCOB : public CommunicationObject
{ ...
  public:
    virtual      ~RxCOB();
    virtual void create();
    virtual void destroy(void);
};

template <class Type>
class CMS_Variable
{
  ....

  protected:
    CommunicationObject * m_cob;
};

template <class Type>
class CMS_ServerVar : public CMS_Variable<Type>
{
  public:
    CMS_ServerVar()
    {
      m_cob = new TxCOB();
      m_cob->create();
    }
};

template <class Type>
class CMS_ClientVar : public CMS_Variable<Type>
{
  public:
    CMS_ServerVar()
    {
      m_cob = new RxCOB();
      m_cob->create();
    }
};

typedef CMS_ServerVar<int> CMS_IntServerVar;
typedef CMS_ClientVar<int> CMS_IntClientVar;

It compiles and links fine, no problem there.


The strange thing is when I use it from the application that is linked
against the ECOS library.

An application like

main()
{
  CMS_IntServerVar server();
  CMS_IntClientVar client();

  return 0;
}

Crashes on the call to m_cob->create(). When I look at the v-table of both
TxCOB and RxCOB, it is partially filled with zeros. (the create function is
a zero, the destroy is not)

If I rewrite the application as follows

main()
{
  TxCOB txcob();
  CommunicationObject * cob = &txcob;
  cob->create()

  CMS_IntServerVar server();
  CMS_IntClientVar client();

  return 0;
}

everything goes fine and the v-tables of both TxCOB and RxCOB are filled in
correctly.
It looks like only classes that are explicitly instantiated outside the ECOS
library have correctly filled in v-tables (although that doesn't make much
sense to me).

Have you ever come accross something like this ?? Or am I doing something
wrong ?? What section are the v-tables stored in anyway (looks like they are
in .rodata, I am not sure though) I use the EcosSWTools that I downloaded
from the web (with the Redhat 6.0 patch)

If you don't know an answer, can you post this on the appropriate discussion
forum please.

Regards,
Bob

------------------------------------------------------------------------
ir. Bob Koninckx
Katholieke Universiteit Leuven
Division Production Engineering,                      tel. +32 16 322535
Machine Design and Automation                         fax. +32 16 322987
Celestijnenlaan 300B                 bob.koninckx@mech.kuleuven.ac.be
B-3001 Leuven Belgium            http://www.mech.kuleuven.ac.be/pma.html
------------------------------------------------------------------------



       reply	other threads:[~1999-10-18  5:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <000501bf195d$2c576080$56183a86@pc086-2.mech.kuleuven.ac.be>
1999-10-18  5:14 ` Jesper Skov [this message]
     [not found]   ` <000601bf1963$2f158760$56183a86@pc086-2.mech.kuleuven.ac.be>
1999-10-18  5:34     ` [ECOS] " Jesper Skov
1999-10-18  5:38   ` [ECOS] " Gary Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14347.3841.654535.829791@thinktwice.zoftcorp.dk \
    --to=jskov@cygnus.co.uk \
    --cc=bob.koninckx@mail.mech.kuleuven.ac.be \
    --cc=ecos-discuss@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).