05-21-2015
Quote:
Originally Posted by
jim mcnamara
Solaris supports memalign() - a malloc variant that allows specification of alignments on a per object basis. We have had to take that approach with some code.
memalign() isn't going to help in this case - malloc() itself has to return "memory suitably aligned for any use". The problem comes from using a structure in such a way that a member that has a strict alignment is offset from the beginning of the structure by an amount that causes the alignment to be wrong. Per the "-xmemalign" documentation from the Solaris Studio "cc" man page:
Quote:
For memory accesses where the alignment cannot be
determined at compile time, the compiler must assume an
alignment to generate the needed load/store sequence.
And
that's why the OPs code that accesses the structure via malloc()'d memory causes a bus error.
It's pretty much the archetype of how to get a SIGBUS error on SPARC.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
This may belong in the C Programming forum, but here goes anyway...
What would cause a bus error? I searched google for a cause, but came up with some conflicting reports...
Could it be caused by disk space?
A lot of the pages I found mentioned linking with the incorrect versions of the... (4 Replies)
Discussion started by: LivinFree
4 Replies
2. UNIX for Dummies Questions & Answers
Hi there
I am running soalris 9 on a sun fire 480r and all of a sudden (today) whenever the users run the command `top` we get the following message `bus error`
does anybody have any information on what this is all about and whether there is a routine i can perform to gather more... (3 Replies)
Discussion started by: hcclnoodles
3 Replies
3. Programming
Hi!
I've got a program which runs fine under Linux, but I have compiled it to run under SunOS 5.8 in a Sparc computer, and now it sometimes fails with "bus error".
Ussing gdb I surfed to the error line, which is
*pointer = some_vector;
where some_vector is a 16 byte struct (4 integers)... (1 Reply)
Discussion started by: shesatmine
1 Replies
4. Solaris
Hi there,
I have two SunBlade 2000s that I want to connect to a single D1000. I am told that I need to do a split bus mode. I don't really understand what that means. Does that mean that half of the storage disks will be assigned to one host and the others to the other host? How do I get... (18 Replies)
Discussion started by: Arkayev
18 Replies
5. UNIX for Dummies Questions & Answers
Hi all,
I am getting bus error problem in SunOS. Can you please help me out in this regard.
Actually, my entire code till the last line has been executed. But after tht i am getting a bus error. Please help me.
Thanks in advance.
Charu. (4 Replies)
Discussion started by: charu
4 Replies
6. HP-UX
I am getting bus error when i include "#!/bin/ksh". If i remove interpreter then script is working. Can anyone explain this and how can i avoid this error?
Operating System is HP-UX B.11.23 U 9000/800 1091834454 (2 Replies)
Discussion started by: anbu23
2 Replies
7. Programming
Hi everyone,
I have a GUI project and when I run it and left in idle state for a long time(there is nothing done, just opened GUI, no more actions),I get bus error after trying to do anything with it.
I've tried to build it in debug mode and use gdb, but I don't get any error in debug mode.It... (3 Replies)
Discussion started by: sisi
3 Replies
8. Programming
Hi all,
I am writing a phonebook program to store names and number using a list. Here is the code for the function which allows the user to enter the name and number (where the error occurs).
//THIS FUNCTION ADDS A NEW ENTRY TO THE phonebook_list
void insert(void){
//variables
int... (5 Replies)
Discussion started by: kdejan
5 Replies
9. Solaris
Hi all,
OS is Solaros 10 Sparc
While doing Netbackup upgradation to 7.5 , the server was asked to reboot.
But then it came up in single user mode,
and after I typed format command it showed some disk error.
bash-3.00# format
Searching for disks...WARNING:... (2 Replies)
Discussion started by: manalisharmabe
2 Replies
LEARN ABOUT REDHAT
posix_memalign
POSIX_MEMALIGN(3) Linux Programmer's Manual POSIX_MEMALIGN(3)
NAME
posix_memalign, memalign, valloc - Allocate aligned memory
SYNOPSIS
#include <stdlib.h>
int posix_memalign(void **memptr, size_t alignment, size_t size);
void *memalign(size_t boundary, size_t size);
void *valloc(size_t size);
DESCRIPTION
The function posix_memalign() allocates size bytes and places the address of the allocated memory in *memptr. The address of the allocated
memory will be a multiple of alignment, which must be a power of two and a multiple of sizeof(void *).
The obsolete function memalign() allocates size bytes and returns a pointer to the allocated memory. The memory address will be a multiple
of boundary, which must be a power of two.
The obsolete function valloc() allocates size bytes and returns a pointer to the allocated memory. The memory address will be a multiple
of the page size. It is equivalent to memalign(sysconf(_SC_PAGESIZE),size).
For all three routines, the memory is not zeroed.
RETURN VALUE
memalign() and valloc() return the pointer to the allocated memory, or NULL if the request fails.
posix_memalign() returns zero on success, or one of the error values listed in the next section on failure. Note that errno is not set.
ERRORS
EINVAL The alignment parameter was not a power of two, or was not a multiple of sizeof(void *).
ENOMEM There was insufficient memory to fulfill the allocation request.
NOTES
posix_memalign() verifies that alignment matches the requirements detailed above. memalign() may not check that the boundary parameter is
correct.
POSIX requires that memory obtained from posix_memalign() can be freed using free(). Some systems provide no way to reclaim memory allo-
cated with memalign() or valloc() (because one can only pass to free() a pointer gotten from malloc(), while e.g. memalign() would call
malloc() and then align the obtained value). GNU libc allows memory obtained from any of these three routines to be reclaimed with free().
GNU libc malloc() always returns 8-byte aligned memory addresses, so these routines are only needed if you require larger alignment values.
AVAILABILITY
The functions memalign() and valloc() have been available in all Linux libc libraries. The function posix_memalign() is available since
glibc 2.1.91.
CONFORMING TO
The function valloc() appeared in 3.0 BSD. It is documented as being obsolete in BSD 4.3, and as legacy in SUSv2. It no longer occurs in
SUSv3. The function memalign() appears in SunOS 4.1.3 but not in BSD 4.4. The function posix_memalign() comes from POSIX 1003.1d.
SEE ALSO
malloc(3), free(3), getpagesize(2), brk(2)
GNU
2001-10-11 POSIX_MEMALIGN(3)