Subject: Atomic SendText nonworkie

From: Tomas Ogren <[email-masked]>
Date: Wed, 17 Mar 1999 16:44:31 +0100

I updated today and noticed that no modules (except FvwmTalk and
FvwmCommandS) worked and tried to figure out why... when I tried to
start other modules from FvwmTalk, it just disappeared...

After a little digging I found some pointer-messing in
libs/Module.c:SendText ... My Solaris/Sparc box does _not_ like accesses
to unaligned pointers...

If I revert Module.c to v1.10, everything works..

/Tomas
-- 
Tomas Ögren, [email-masked], http://www.ing.umu.se/~stric/
|- Student of Computer Science at the University of Umeå
`- Sysadmin at {cs,ing,acc}.umu.se
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Brad Giaccio <[email-masked]>
Date: Wed, 17 Mar 1999 10:49:14 -0500

this is the same problem I'm having its just that I only get as far as
running FvwmM4, which I just noticed does dump core however when I run
gdb this is what I get "/home/bgiaccio/core" is not a core dump: File
format not recognized

anyone see that before, yes I'm running the same build version of gcc
and gdb.

Brad

On Wed, Mar 17, 1999 at 04:44:31PM +0100, Tomas Ogren wrote:

> libs/Module.c:SendText ... My Solaris/Sparc box does _not_ like
> accesses to unaligned pointers...
>

-- 
--- There are two kinds of knowledge, you either know the answer or
			you know where to find it
		      -Kane, Johnson, and anonymous
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: [email-masked] (Paul D. Smith)
Date: 17 Mar 1999 11:02:33 -0500

%% Tomas Ogren <[email-masked]> writes:

  to> After a little digging I found some pointer-messing in
  to> libs/Module.c:SendText ... My Solaris/Sparc box does _not_ like accesses
  to> to unaligned pointers...

    w = strlen (message);
      ...
    p += w;
    *((int*)p) = 1;

Ouch!  No, no.  Very bad.  Will fail on any RISC processor.  Very
non-compliant C.

You're going to have to calculate the offset padded for integer
alignment.

I recommend s'thing like:

  * declare buf to be an array of long ints, not char.  This lets you
    index it as an integer array and ensure the offsets are
    appropriate.

  * when writing the message, add enough to the offset to handle the
    padding.

For example:

  long buf[256];    /* 1024 bytes where sizeof(long) == 4 */
  long *p = buf;
  int w;

  if (message == NULL)
    return;

  *(p++) = window;

  w = strlen(message);
  *(p++) = w;

  strncpy ((char *)p, message, 1000); /* bogus magic number :( */
  p += (w / sizeof(long)) + ((w % sizeof(long)) != 0);

  *(p++) = 1;

  write(fd[0], (char *)buf, (char *)p - (char *)buf);

Or something.  May require a little testing, this is totally untested :)

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]