Using Sun libtask Interrupt_handler()

Using Sun libtask Interrupt_handler()

Post by Sandro Morandin » Tue, 14 Dec 1999 04:00:00



Hi all,

I have started with a simple example and I am trying
to use the task library to implement a signal handler.

It runs on a Sparc compiled with Suns CC but when
I run the same example on a i386 machine (SysV release 4.0)
compiled with an AT&T CC it crashes (segmentation fault).

I have no de* tools on the latter one so i started
purify  on sun and this is the result.

      SBR: Stack array bounds read (27 times)
      This is occurring while in:
            *unknown func* [pc=0x5f104]
            task::task(char*, task::modetype, int) [libtask.a]
            Interrupt_alerter::Interrupt_alerter(void) [libtask.a]
            _init          [crti.o]
            _start         [crt1.o]
      Reading 4 bytes from 0xffbeee48.
      Frame pointer 0xffbeee40

      MSE: Memory segment error
      This is occurring while in:
            _p860static    [rtlib.o]
            _p895static    [rtlib.o]
            *unknown func* [pc=0x5f1d8]
            task::task(char*, task::modetype, int) [libtask.a]
            Interrupt_alerter::Interrupt_alerter(void) [libtask.a]
      Accessing a memory range that crosses a memory segment boundary.
      Addressing 0x94498 for -4871768 bytes ending at 0xffbeee40,
      beginning in the heap which ends at 0x500000.

This is the Example:

#include <sys/time.h>
#include <signal.h>
#include <iostream.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>

/////// class ETimer_handler

#include "task.h"

class ETimer_handler : public Interrupt_handler
{

public:
    ETimer_handler(int sig);
    ~ETimer_handler();
private:
    void interrupt();

Quote:};

ETimer_handler::
ETimer_handler(int sig)
  :Interrupt_handler(sig)
  {
  }

ETimer_handler::
~ETimer_handler()
  {
  }

void
ETimer_handler::
interrupt()
  {
  cout << "." << flush;
  }

////// end   ETimer_handler

int main(int argc,char** argv)
  {
  struct itimerval itimer_value;

  // value to be used in reloading it_value when the timer expires
  // Setting it_interval to 0 disables a timer after its next expiration
  itimer_value.it_interval.tv_sec  = 1;
  itimer_value.it_interval.tv_usec = 0;

  // time to next timer expiration
  // Setting it_value  to  0 disables a timer,
  // regardless of the value of it_interval
  itimer_value.it_value.tv_sec     = 1;
  itimer_value.it_value.tv_usec    = 0;

  // Install timer
  // A  SIGALRM  signal  is delivered when this timer expires
  setitimer(ITIMER_REAL,&itimer_value,0);

  ETimer_handler timer_ih(SIGALRM);
  while(1);
  return 0;
  }

I have no idea what the problem is. Any help would be
appreciated. Thank you.

Sandro Morandini

 
 
 

Using Sun libtask Interrupt_handler()

Post by Michael Loftu » Sat, 18 Dec 1999 04:00:00


Just a guess:

Problem 1:
I assume the base class constructor calls
something like signal(), passing member
function interrupt(). Your derived class
member (which does not yet exist) will not
be called. (Investigate virtual constructors.)

Problem 2:
Member function interrupt() should be static
to satisfy the function signature expected by
signal(), and thus it cannot be virtual.
Overloading interrupt() is pointless.

If some pointer trickery is used to overcome
the function signature, I would consider your
compiler to be broken. The following should not
be allowed:

void (*vfp)(int) = (void(*)(int))(BaseClass::interrupt);
signal(signo, vfp);

(C cast shown - C++ style casts will also fail with
a good compiler)

BTW, I am not familiar with any "task" library. If it
is homegrown, you have some more work to do.

--

Michael Loftus
(my real address has no 'x')
Ford Research Labs

*** I am not an official spokesperson for Ford Motor Co. ***


> Hi all,

> I have started with a simple example and I am trying
> to use the task library to implement a signal handler.

> It runs on a Sparc compiled with Suns CC but when
> I run the same example on a i386 machine (SysV release 4.0)
> compiled with an AT&T CC it crashes (segmentation fault).

> I have no de* tools on the latter one so i started
> purify  on sun and this is the result.

>       SBR: Stack array bounds read (27 times)
>       This is occurring while in:
>             *unknown func* [pc=0x5f104]
>             task::task(char*, task::modetype, int) [libtask.a]
>             Interrupt_alerter::Interrupt_alerter(void) [libtask.a]
>             _init          [crti.o]
>             _start         [crt1.o]
>       Reading 4 bytes from 0xffbeee48.
>       Frame pointer 0xffbeee40

>       MSE: Memory segment error
>       This is occurring while in:
>             _p860static    [rtlib.o]
>             _p895static    [rtlib.o]
>             *unknown func* [pc=0x5f1d8]
>             task::task(char*, task::modetype, int) [libtask.a]
>             Interrupt_alerter::Interrupt_alerter(void) [libtask.a]
>       Accessing a memory range that crosses a memory segment boundary.
>       Addressing 0x94498 for -4871768 bytes ending at 0xffbeee40,
>       beginning in the heap which ends at 0x500000.

> This is the Example:

> #include <sys/time.h>
> #include <signal.h>
> #include <iostream.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <stdio.h>
> #include <time.h>

> /////// class ETimer_handler

> #include "task.h"

> class ETimer_handler : public Interrupt_handler
> {

> public:
>     ETimer_handler(int sig);
>     ~ETimer_handler();
> private:
>     void interrupt();
> };

> ETimer_handler::
> ETimer_handler(int sig)
>   :Interrupt_handler(sig)
>   {
>   }

> ETimer_handler::
> ~ETimer_handler()
>   {
>   }

> void
> ETimer_handler::
> interrupt()
>   {
>   cout << "." << flush;
>   }

> ////// end   ETimer_handler

> int main(int argc,char** argv)
>   {
>   struct itimerval itimer_value;

>   // value to be used in reloading it_value when the timer expires
>   // Setting it_interval to 0 disables a timer after its next expiration
>   itimer_value.it_interval.tv_sec  = 1;
>   itimer_value.it_interval.tv_usec = 0;

>   // time to next timer expiration
>   // Setting it_value  to  0 disables a timer,
>   // regardless of the value of it_interval
>   itimer_value.it_value.tv_sec     = 1;
>   itimer_value.it_value.tv_usec    = 0;

>   // Install timer
>   // A  SIGALRM  signal  is delivered when this timer expires
>   setitimer(ITIMER_REAL,&itimer_value,0);

>   ETimer_handler timer_ih(SIGALRM);
>   while(1);
>   return 0;
>   }

> I have no idea what the problem is. Any help would be
> appreciated. Thank you.

> Sandro Morandini

--

Michael Loftus
(my real address has no 'x')
Ford Research Labs

*** I am not an official spokesperson for Ford Motor Co. ***

 
 
 

Using Sun libtask Interrupt_handler()

Post by Michael Loftu » Sun, 19 Dec 1999 04:00:00


On my own machine now, Sol7 with C/C++ 4.2 installed.
I found the Sun "task" man pages - all dated from the
first half of this decade. Older compilers allow some
pretty odd stuff by today's std.

"man interrupt" alone describes behavior I would
expect not to work anymore, for the reasons I provided
earlier. I just quickly reviewed the task tutorial in
the answerbook - yikes!

If you are starting a new project, just pretend
you never heard of this "task" package. Try
pthreads instead - they will be much more portable.

ML


> Just a guess:

> Problem 1:
> I assume the base class constructor calls
> something like signal(), passing member
> function interrupt(). Your derived class
> member (which does not yet exist) will not
> be called. (Investigate virtual constructors.)

> Problem 2:
> Member function interrupt() should be static
> to satisfy the function signature expected by
> signal(), and thus it cannot be virtual.
> Overloading interrupt() is pointless.

> If some pointer trickery is used to overcome
> the function signature, I would consider your
> compiler to be broken. The following should not
> be allowed:

> void (*vfp)(int) = (void(*)(int))(BaseClass::interrupt);
> signal(signo, vfp);

> (C cast shown - C++ style casts will also fail with
> a good compiler)

> BTW, I am not familiar with any "task" library. If it
> is homegrown, you have some more work to do.

 
 
 

1. HELP: need reference for libtask.a file

Hi All,

We are between sys admins right now and one of our programmers is having
a problem.

Can someone help me identify what package includes the file
/usr/lpp/xlC/lib/libtask.a

It doesn't appear to be in the C Set++ 3.6.4 or xlC that comes with bos
4.3.2

Any and all help is greatly appreciated.  Please copy responses to my
email address as I am not able to monitor this group as regularly as I
might like.

Thanks,

Eric Taggart
University of California

(949) 824-4385

2. Netboot/Etherboot

3. Anyone used Sun ShowMe video package using Solaris 2.4?

4. LILO hangs with "02 02 02..." message

5. project SUN N1, SUN PFTS, SUN SOUS

6. xmodem and zmodem info

7. mod_perl and Apache in RH6.0

8. Using Linux to develop Sun X-app

9. info on large production print using E10k sun machine

10. [=== Problem using 2GB DAT drive with SUN Solaris ===]

11. Used Sun connection

12. SUN's mouse used for PC PS/2 mouse port ??