Memory Alignment Problem on Sun Sparcs


 
Thread Tools Search this Thread
Operating Systems Solaris Memory Alignment Problem on Sun Sparcs
# 1  
Old 09-21-2005
Memory Alignment Problem on Sun Sparcs

Hi, I try to marshal a unsigned int and a char * into a buffer, and then unmarshal them later to get them out. I need to put the char * in the front and unsigned int at the end of the buffer. However, my system always give me "BUS ERROR". I am using Sun Sparcs Sloris 2.10.

My code to marshal the data:

unsigned dev = 111;
unsigned inode = 222;

int s_docname = strlen(docname) + 1;
int s_key = s_docname + sizeof(unsigned) * 2;

keybuf = malloc(s_key);
memset(keybuf, 0, s_key);
memcpy(keybuf, docname, s_docname);
memcpy(keybuf + s_docname, &(dev), sizeof(unsigned));
memcpy(keybuf + s_docname + sizeof(unsigned), &(inode),
sizeof(unsigned));

My code to unmarshal the data:
char * docname = (char *)key.data;
int s_docname = strlen(docname) + 1;
dev =*((unsigned *)((char *)key.data + s_docname));
inode = *((unsigned *)((char *)key.data + s_docname +
sizeof(unsigned)));

I can print the dev and inode out in dbx debugger by typing the same
code, but running the program always have the BUS error.

I realize this is a problems of memory alignement. s_docname has byte granularity, somehow I need to "round up" my s_docname by some suitable calculation. But I really don't know how to? Help is appreciated.
# 2  
Old 09-21-2005
Please read the rules:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Fsck: alignment error Solaris 8, SUN Netra AX11505

Hello all, I recently powered on my Netra AX1105 server only to be greeted with the following error message. I am not sure what to do here, I cant fun fsck on OK prompt.. did ok>boot -r and now it keeps booting from net, then I run ok>boot disk then outputs the following message... and keeps... (3 Replies)
Discussion started by: br1an
3 Replies

2. Shell Programming and Scripting

Text qualifier issue causing data alignment problem

Hello Everyone, I have a csv file with text qualifier as "" and data similar to below: "1","abc","address1","US" "2","def","address1 "characters in double-quote" address2","IND" "3","ghi","address1","UK" In above example, for record 2, we have an issue as in column3 contains double... (2 Replies)
Discussion started by: AnkitSenghani
2 Replies

3. What is on Your Mind?

Sun Sparcs

I used to have a Sparcstation20 some years ago with one of the HUGE HEAVY Sun monitors. I regret having gotten rid of it. Does anyone know where I can find a working sparcstation, monitor, keyboard, mouse these days?? (1 Reply)
Discussion started by: bsdforme
1 Replies

4. Shell Programming and Scripting

Output alignment problem

Hi Gurus, This is my raw data. How would I able to format this output into a better alignment? /dev/vg00/lvol5 /home 0.12 GB 0.02 GB 0.10 GB 19% /dev/vg00/misc /misc 28.43 GB 4.92 GB 23.51 GB 17% /dev/vg00/lvol6 /opt 8.25 GB 5.43 GB 2.82 GB 65% /dev/vgsap/ora10264 ... (10 Replies)
Discussion started by: superHonda123
10 Replies

5. Solaris

how to get cpu and memory configuration on sun

Hi folks, can you please help to print cpu and memory configuration on sun host. (4 Replies)
Discussion started by: ggolub
4 Replies

6. Shell Programming and Scripting

Text Alignment Problem

Dear Friends, I've one file "sample.log" with the below comma separated lines: BOND_FORWARD,0 succeeded,0 failed. EQUITY_FORWARD,0 succeeded,0 failed. FRA,12 succeeded,0 failed. OPTION_BAR,16 succeeded,0 failed. OPTION_VAN,76 succeeded,0 failed. RENTOPT_CAP_FLOOR,4775 succeeded,0 failed.... (2 Replies)
Discussion started by: ganapati
2 Replies

7. Solaris

Memory Check in SUN Solaris

Hi I am facing a problem with memory in SunOS 5.9. I just want to check the memory usage. Can anybody suggest me a command that will help me in this regard. (4 Replies)
Discussion started by: rajarsi.ghosh
4 Replies

8. Programming

how to round up a memory address(memory alignment problem)

Hi, I try to marshal a unsigned int and a char * into a buffer, and then unmarshal them later to get them out. I need to put the char * in the front and unsigned int at the end of the buffer. However, my system always give me "BUS ERROR". I am using Sun Sparcs Sloris 2.10. My code to marshal... (6 Replies)
Discussion started by: nj302
6 Replies

9. UNIX for Dummies Questions & Answers

ls command alignment problem

With older Linux servers, the command: ls -al would output text that would have the filenames all lined up in the same column (the owner and group names were truncated to produce a uniform right column). In newer distros (i.e. RHEL 3), the command will push the right column out when owners... (0 Replies)
Discussion started by: robf
0 Replies

10. Solaris

SUN station memory problem

The problem is that I use this station as a remote computer for an AOI Orbotech machine and in the root of the station there is no memory available and on the refmgr folder on the same station there are 5GB free memory. So if anyone knows how can I free some space and not damaging the root files,... (0 Replies)
Discussion started by: Dac
0 Replies
Login or Register to Ask a Question