public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Pool <mbp@sourcefrog.net>
To: linux-ia64@vger.kernel.org
Subject: Re: a question about memory access on IA64
Date: Fri, 16 Jan 2004 04:16:24 +0000	[thread overview]
Message-ID: <20040116041624.GA766@happy.sourcefrog.net> (raw)
In-Reply-To: <40075464.6010202@sinosoft.com.cn>

[-- Attachment #1: Type: text/plain, Size: 2039 bytes --]

On 16 Jan 2004, liuduo <liuduo@sinosoft.com.cn> wrote:
> David:
> Sorry, i only describe the process about the error occurs .
> 
>    typedef struct b{
>      char*  pDescriptName;
>      char*           pVendorName;
>      unsigned int	RevisionID;
>     }B;
> 
>    typedef struct pci{
>     int c;
>     struct b bb[512];
>     }PCI;
> 
> int main()
> {
> 
> 
>     struct pci a;
> 
>     //function for operation a
>     func(&a);
>     return 0;
> }

> the func is in an lib, it's an lib export function, and the func is as 
> follows;

Do you mean that it works if you use the first struct definition, and
if you pu the func into the same file?  Does it have to be in a
library to fail?

Could it be that you are using different structure packing for
building the library, either through compiler options or #pragmas in
some other header file?

> 
> func(struct pci* a)
> {
>      char tmp[256];
>     for(num=0;num<512;num++)
>     {
>      a->bb[num].pDescriptName = (char*)malloc(100);
>      strcpy(a->bb[num].pDescriptName , "dddd");
>      a->bb[num].pVendorName = (char*)malloc(100);
>      strcpy(a->bb[num].pVendorName , "fffff");
>      a->bb[num].RevisionID = 22;
>     }
>     a->c = 512;
> }
> when call the func , the segmentation fault occurs,
> and then we modified the struct A as follows
>     typedef struct pci{
>     struct b bb[512];
>     int c;
>     }PCI;
> it's normal.
> please tell me why?
> thanks a lot.
> -- 
> =======================================
> Liu duo
> tel:(010)62570007-509
> email:liuduo@sinosoft.com.cn
> Sinosoft Software.Co.Ltd.
> Esmpro Group.Secic Department
> =======================================
> 
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Martin

"all the hardcore hackers use aol"
    - Joseph "joey" Sarrach <mrfr0sty@home.com>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2004-01-16  4:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-16  3:03 a question about memory access on IA64 liuduo
2004-01-16  3:16 ` David Mosberger
2004-01-16  3:56 ` liuduo
2004-01-16  4:16 ` Martin Pool [this message]
2004-01-16  4:59 ` David Mosberger
2004-01-16  7:01 ` Martin Pool
2004-01-16  7:12 ` liuduo

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=20040116041624.GA766@happy.sourcefrog.net \
    --to=mbp@sourcefrog.net \
    --cc=linux-ia64@vger.kernel.org \
    /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