Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
@ 1993-11-08 12:50 Joseph Jacob
  1993-11-08 15:32 ` John T. Kohl
  1993-11-09  4:26 ` Karen Kolling
  0 siblings, 2 replies; 10+ messages in thread
From: Joseph Jacob @ 1993-11-08 12:50 UTC (permalink / raw)


Hi,

We are trying to port the Charm programming environment to the DEC Alphas.
We  ported Charm to HPs and RS6000s with success.
But, on the DEC Alpa machine, running OSF ,we have here we get

Unaligned access pid=4493 <hpgm> va=14008c01c pc=1200068e8 ra=1200068d8 type=stq

when we try to run the program. 
we found that it is coming at the following lines of code 

    temp = (struct NODE *)(  mem_space+1);
    temp->next= (struct NODE *)NULL ;
    temp->left =  (struct NODE *)NULL ;
    temp->right = (struct NODE *)NULL ;
    temp->parent = (struct NODE *)NULL ;

where temp is defined as struct NODE *temp;
struct NODE {
	struct NODE *next ;
        struct NODE  *left ;
	struct NODE *right ;
	struct NODE *parent ;
	} ;
mem_space is defined as 
int *mem_space ;
all the variables used above are local to the function in which
they are used.

the last four lines give rise to issual of unaligned access message
by the operating system [ On the DEC Alphas]. These run just fine
on other machines CHARM has been ported to !!.

The compiler which we used to compile the program is the C compiler
provided by DEC.

Please reply as soon as possible.

thank you,

Joseph Jacob


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
  1993-11-08 12:50 HELP!! : Unaligned access error on DEC Alpha, $OS == osf1 Joseph Jacob
@ 1993-11-08 15:32 ` John T. Kohl
  1993-11-08 20:22   ` John T. Kohl
  1993-11-09  4:26 ` Karen Kolling
  1 sibling, 1 reply; 10+ messages in thread
From: John T. Kohl @ 1993-11-08 15:32 UTC (permalink / raw)


In article <2blfa2INN4sq@flop.ENGR.ORST.EDU> jacobj@research.CS.ORST.EDU (Joseph Jacob) writes:

> when we try to run the program. 
> we found that it is coming at the following lines of code 

>     temp = (struct NODE *)(  mem_space+1);
>     temp->next= (struct NODE *)NULL ;
> ...

> where temp is defined as struct NODE *temp;
> struct NODE {
> 	struct NODE *next ;
> ...

> mem_space is defined as 
> int *mem_space ;

Yep, that'll do it.  If mem_space is an integer pointer, as you
indicated, it will be aligned on a 4-byte boundary.  Pointers must be
aligned on 8-byte boundaries to avoid unaligned access problems.  It's
likely that mem_space itself is 8-byte aligned, so that mem_space+1 is
only 4-byte aligned, hence the problems you see.
--
John Kohl <jtk@atria.com> or <jtkohl@mit.edu>
working for but not representing:	Atria Software
---------
What are you pretending not to know?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
  1993-11-08 15:32 ` John T. Kohl
@ 1993-11-08 20:22   ` John T. Kohl
  1993-11-09 12:29     ` acssysdsc
  0 siblings, 1 reply; 10+ messages in thread
From: John T. Kohl @ 1993-11-08 20:22 UTC (permalink / raw)


In article <CG6J69.1rt@atria.com>, I wrote:

> Pointers must be
> aligned on 8-byte boundaries to avoid unaligned access problems.

Let me rephrase that to make sure it's not misleading.  _Storage_ for
pointers must be aligned on 8-byte boundaries.  To avoid unaligned
access problems, pointer _values_ need to be aligned to the natural
alignment of the item to which they point.
--
John Kohl <jtk@atria.com> or <jtkohl@mit.edu>
working for but not representing:	Atria Software
---------
What are you pretending not to know?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
  1993-11-08 12:50 HELP!! : Unaligned access error on DEC Alpha, $OS == osf1 Joseph Jacob
  1993-11-08 15:32 ` John T. Kohl
@ 1993-11-09  4:26 ` Karen Kolling
  1993-11-09 17:06   ` Bruce O'Neel
  1 sibling, 1 reply; 10+ messages in thread
From: Karen Kolling @ 1993-11-09  4:26 UTC (permalink / raw)


In article <2blfa2INN4sq@flop.ENGR.ORST.EDU> jacobj@research.CS.ORST.EDU (Joseph Jacob) writes:
>Hi,
>
>We are trying to port the Charm programming environment to the DEC Alphas.
>We  ported Charm to HPs and RS6000s with success.
>But, on the DEC Alpa machine, running OSF ,we have here we get
>
>Unaligned access pid=4493 <hpgm> va=14008c01c pc=1200068e8 ra=1200068d8 type=stq
>

I think it's unhappy because pointers are 64 bit items while ints are 32
bits, and you're trying to store into space that is not 64 bit aligned.
Run lint -Q on your code.
-- 
Karen Kolling        kolling@adobe.com or kolling@netcom.com

 ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
  1993-11-08 20:22   ` John T. Kohl
@ 1993-11-09 12:29     ` acssysdsc
  1993-11-09 20:26       ` Karen Kolling
  1993-11-10 15:06       ` Ken Cowan
  0 siblings, 2 replies; 10+ messages in thread
From: acssysdsc @ 1993-11-09 12:29 UTC (permalink / raw)


In article <CG6wLL.4MF@atria.com>, jtk@atria.com (John T. Kohl) writes:
> In article <CG6J69.1rt@atria.com>, I wrote:
> 
>> Pointers must be
>> aligned on 8-byte boundaries to avoid unaligned access problems.
> 
> Let me rephrase that to make sure it's not misleading.  _Storage_ for
> pointers must be aligned on 8-byte boundaries.  To avoid unaligned
> access problems, pointer _values_ need to be aligned to the natural
> alignment of the item to which they point.
> --

So what does he have to do to fix it? Does C have an align statement or 
directive?

dsc

> John Kohl <jtk@atria.com> or <jtkohl@mit.edu>
> working for but not representing:	Atria Software
> ---------
> What are you pretending not to know?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
  1993-11-09  4:26 ` Karen Kolling
@ 1993-11-09 17:06   ` Bruce O'Neel
  1993-11-09 23:06     ` HELP!! : Unaligned access error on DEC John Lovell
  0 siblings, 1 reply; 10+ messages in thread
From: Bruce O'Neel @ 1993-11-09 17:06 UTC (permalink / raw)


kolling@adobe.com (Karen Kolling) writes:

>In article <2blfa2INN4sq@flop.ENGR.ORST.EDU> jacobj@research.CS.ORST.EDU (Joseph Jacob) writes:
>>Hi,
>>
>>We are trying to port the Charm programming environment to the DEC Alphas.
>>We  ported Charm to HPs and RS6000s with success.
>>But, on the DEC Alpa machine, running OSF ,we have here we get
>>
>>Unaligned access pid=4493 <hpgm> va=14008c01c pc=1200068e8 ra=1200068d8 type=stq
>>

>I think it's unhappy because pointers are 64 bit items while ints are 32
>bits, and you're trying to store into space that is not 64 bit aligned.
>Run lint -Q on your code.

I wasn't the origional person, but I have a similiar question.


We have code in both fortran and C, and when we call a c routine from
fortran we get exactly this message.  I figured it was a pointer
alignment problem (since we pass pointers to the C routine, fortran
remember?) but is there a way to solve this?

Thanks for any and all help!

bruce

--
For every problem there is one solution which is simple, neat, and
wrong. -- H.L. Mencken


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
  1993-11-09 12:29     ` acssysdsc
@ 1993-11-09 20:26       ` Karen Kolling
  1993-11-09 20:45         ` Karen Kolling
  1993-11-10 15:06       ` Ken Cowan
  1 sibling, 1 reply; 10+ messages in thread
From: Karen Kolling @ 1993-11-09 20:26 UTC (permalink / raw)


In article <1993Nov9.072931.639@acs.eku.edu> acssysdsc@acs.eku.edu writes:
>In article <CG6wLL.4MF@atria.com>, jtk@atria.com (John T. Kohl) writes:
>> In article <CG6J69.1rt@atria.com>, I wrote:
>> 
>>> Pointers must be
>>> aligned on 8-byte boundaries to avoid unaligned access problems.
>> 
>> Let me rephrase that to make sure it's not misleading.  _Storage_ for
>> pointers must be aligned on 8-byte boundaries.  To avoid unaligned
>> access problems, pointer _values_ need to be aligned to the natural
>> alignment of the item to which they point.
>> --
>
>So what does he have to do to fix it? Does C have an align statement or 
>directive?


I don't think so.  If he's storing just 64 bit items, and ignoring for
the moment that "+1", he could just defined mem_space as a pointer to
any 64 bit item instead of int.  I don't know what the +1 is for --
maybe it's a count of used space or somesuch and can be set up
separately, or he could point mem_space at a struct of an int and a 64
bit item.  Or maybe it itself should actually be 64 bits long and not
an int (if, for example, it's for a pointer to free space).  Or maybe
he's storing items of varying sizes in mem_space and really needs to
manage the space...




-- 
Karen Kolling        kolling@adobe.com or kolling@netcom.com

 ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
  1993-11-09 20:26       ` Karen Kolling
@ 1993-11-09 20:45         ` Karen Kolling
  0 siblings, 0 replies; 10+ messages in thread
From: Karen Kolling @ 1993-11-09 20:45 UTC (permalink / raw)


In article <1993Nov9.202614.1396@adobe.com> kolling@adobe.com (Karen Kolling) writes:
>
>I don't think so.  If he's storing just 64 bit items, and ignoring for
>the moment that "+1", he could just defined mem_space as a pointer to
>any 64 bit item instead of int.  I don't know what the +1 is for --
>maybe it's a count of used space or somesuch and can be set up
>separately, or he could point mem_space at a struct of an int and a 64
>bit item.  Or maybe it itself should actually be 64 bits long and not
>an int (if, for example, it's for a pointer to free space).  Or maybe
>he's storing items of varying sizes in mem_space and really needs to
>manage the space...


Probably make that "he could point mem_space at a struct of an int and an
array of 64 bit items"
^^^^^^^^
-- 
Karen Kolling        kolling@adobe.com or kolling@netcom.com

 ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^ ^._.^


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: HELP!! : Unaligned access error on DEC
  1993-11-09 17:06   ` Bruce O'Neel
@ 1993-11-09 23:06     ` John Lovell
  0 siblings, 0 replies; 10+ messages in thread
From: John Lovell @ 1993-11-09 23:06 UTC (permalink / raw)


In article fs4@skates.gsfc.nasa.gov, oneel@athena.gsfc.nasa.gov (Bruce O'Neel) writes:
>
>We have code in both fortran and C, and when we call a c routine from
>fortran we get exactly this message.  I figured it was a pointer
>alignment problem (since we pass pointers to the C routine, fortran
>remember?) but is there a way to solve this?
>
>Thanks for any and all help!
>
>bruce
>

Calling C from FORTRAN and vice versa should not necessarily cause you problems on the Alpha. One possibility could be that you are mixing floating point
and double precision addresses. Recall that with ANSI C, given

void test(x)
float x;
{
}

then x must be aligned on a double word boundary but with

void test(float x)
{
}

then x can be aligned on a single word boundary. (To my mind this is a screw-up
with ANSI C, but that's a different issue...)

Regards,

John Lovell, Schlumberger-Doll, Ridgefield, CT 06877
lovell@sdr.slb.com, 203-431-5560








^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
  1993-11-09 12:29     ` acssysdsc
  1993-11-09 20:26       ` Karen Kolling
@ 1993-11-10 15:06       ` Ken Cowan
  1 sibling, 0 replies; 10+ messages in thread
From: Ken Cowan @ 1993-11-10 15:06 UTC (permalink / raw)



In article <1993Nov9.072931.639@acs.eku.edu>, acssysdsc@acs.eku.edu writes:
|>Path: jac.zko.dec.com!pa.dec.com!decwrl!olivea!spool.mu.edu!howland.reston.ans.net!paladin.american.edu!gatech!psuvax1!rutgers!ukma!acs.eku.edu!acssysdsc
|>From: acssysdsc@acs.eku.edu
|>Newsgroups: comp.sys.dec
|>Subject: Re: HELP!! : Unaligned access error on DEC Alpha, $OS == osf1
|>Message-ID: <1993Nov9.072931.639@acs.eku.edu>
|>Date: Tue, 9 Nov 93 07:29:31 EST
|>References: <2blfa2INN4sq@flop.ENGR.ORST.EDU> <CG6J69.1rt@atria.com> <CG6wLL.4MF@atria.com>
|>Organization: Eastern Kentucky University
|>Lines: 21
|>
|>In article <CG6wLL.4MF@atria.com>, jtk@atria.com (John T. Kohl) writes:
|>> In article <CG6J69.1rt@atria.com>, I wrote:
|>> 
|>>> Pointers must be
|>>> aligned on 8-byte boundaries to avoid unaligned access problems.
|>> 
|>> Let me rephrase that to make sure it's not misleading.  _Storage_ for
|>> pointers must be aligned on 8-byte boundaries.  To avoid unaligned
|>> access problems, pointer _values_ need to be aligned to the natural
|>> alignment of the item to which they point.
|>> --
|>
|>So what does he have to do to fix it? Does C have an align statement or 
|>directive?
|>
|>dsc
|>
|>> John Kohl <jtk@atria.com> or <jtkohl@mit.edu>
|>> working for but not representing:	Atria Software
|>> ---------
|>> What are you pretending not to know?
|>

It looks like the structure is really:

struct foo {
	int m;		/* a field that tracks "mem space"
        struct NODE n;	/* the struct here, not pointer to struct */
 	}

If declared and allocated this way, the compiler will
pad or pack the structure, as you tell it and will never generate
alignment faults.  When declare a pointer:

int *mem;

then "mem + 1" is the address of the next int.  That's not the
same as telling the compiler that the next item is a struct NODE.
By doing the cast, that says that the place where the next int
is supposed to be is really a struct NODE.  That's different
than saying to go to the place where the next struct NODE should be.

When ints are the same size as pointers, both have the same
alignment requirements and so both the packed and padded alignments
of the struct result in the same memory layout.

How to fix it?  Either tell the compiler that your struct NODE
pointer has a base alignment of 4-bytes (via align(4), I think),
or allocate "mem_space" as part of a larger structure, or change
"int *mem_space" to "long int *mem_space".  This last hack gets
back to the sizeof(xxx) = sizeof(pointer) axiom.
--
Ken Cowan, ZK2-3/Q8				cowan@rtl.enet.dec.com
Digital Equipment Corporation			decwrl!rtl!cowan
110 Spit Brook Rd,
Nashua, NH 03062


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1993-11-10 15:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-11-08 12:50 HELP!! : Unaligned access error on DEC Alpha, $OS == osf1 Joseph Jacob
1993-11-08 15:32 ` John T. Kohl
1993-11-08 20:22   ` John T. Kohl
1993-11-09 12:29     ` acssysdsc
1993-11-09 20:26       ` Karen Kolling
1993-11-09 20:45         ` Karen Kolling
1993-11-10 15:06       ` Ken Cowan
1993-11-09  4:26 ` Karen Kolling
1993-11-09 17:06   ` Bruce O'Neel
1993-11-09 23:06     ` HELP!! : Unaligned access error on DEC John Lovell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox