Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > invalid address alignment

Reply
Thread Tools

invalid address alignment

 
 
ADS7328
Guest
Posts: n/a
 
      05-22-2007

Dear ,

My C++ program crashes with the following error:
SIGNAL BUS (invalid addresses aligment)
at random pleaces.



t@1 (l@1) signal BUS (invalid address alignment) in
__rwstd::digit_writer<char,std:streambuf_iterato r
<char,std::char_traits<char> > >:ut_digits at 0xfdf09af0
0xfdf09af0: put_digits+0x0298: ld [%o0], %l5
Current function is Analytic::Schedule (optimized)
4838 str << " " << ":R" << ":::"
<< "01/01/1900" << ":" << DF ;
(dbx) quit

Thanks in advance

bye
Tony

 
Reply With Quote
 
 
 
 
Gianni Mariani
Guest
Posts: n/a
 
      05-22-2007
ADS7328 wrote:
> Dear ,
>
> My C++ program crashes with the following error:
> SIGNAL BUS (invalid addresses aligment)
> at random pleaces.
>
>
>
> t@1 (l@1) signal BUS (invalid address alignment) in
> __rwstd::digit_writer<char,std:streambuf_iterato r
> <char,std::char_traits<char> > >:ut_digits at 0xfdf09af0
> 0xfdf09af0: put_digits+0x0298: ld [%o0], %l5
> Current function is Analytic::Schedule (optimized)
> 4838 str << " " << ":R" << ":::"
> << "01/01/1900" << ":" << DF ;
> (dbx) quit


Usually a bad cast. Are you casting to values directly from a char *
somewhere ? The compiler usually does not do this.

The resolution to this is to either use some compiler specific features
(like #pragma pack) or read a byte at a time.

The information you provide above is next to useless to us. Is it IRIX?

 
Reply With Quote
 
 
 
 
ADS7328
Guest
Posts: n/a
 
      05-22-2007
On May 22, 2:09 pm, Gianni Mariani <gi3nos...@mariani.ws> wrote:
> ADS7328 wrote:
> > Dear ,

>
> > My C++ program crashes with the following error:
> > SIGNAL BUS (invalid addresses aligment)
> > at random pleaces.

>
> > t@1 (l@1) signal BUS (invalidaddressalignment) in
> > __rwstd::digit_writer<char,std:streambuf_iterato r
> > <char,std::char_traits<char> > >:ut_digits at 0xfdf09af0
> > 0xfdf09af0: put_digits+0x0298: ld [%o0], %l5
> > Current function is Analytic::Schedule (optimized)
> > 4838 str << " " << ":R" << ":::"
> > << "01/01/1900" << ":" << DF ;
> > (dbx) quit

>
> Usually a bad cast. Are you casting to values directly from a char *
> somewhere ? The compiler usually does not do this.
>
> The resolution to this is to either use some compiler specific features
> (like #pragma pack) or read a byte at a time.
>
> The information you provide above is next to useless to us. Is it IRIX?


Thanks a lot, I'm working on Solaris 2.8

I changed into :

double DF= 0.0 ;

ostringstream str ;

str << " " << ":R" << ":::" <<
"01/01/1900" << ":" << DF ;

and I deleted the

str.~ostingstream() ;


and it seems to work fine.


But I don't undertsand if the entry " str.~ostringstream() "
was the problem.


bye
Tony












 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      05-22-2007
ADS7328 wrote:
> [..]
> I changed into :
>
> double DF= 0.0 ;
>
> ostringstream str ;
>
> str << " " << ":R" << ":::" <<
> "01/01/1900" << ":" << DF ;
>
> and I deleted the
>
> str.~ostingstream() ;
>
>
> and it seems to work fine.
>
>
> But I don't undertsand if the entry " str.~ostringstream() "
> was the problem.


If you were doing

char storage[sizeof(SomeType)];
SomeType *myObject = new (storage) SomeType;

it is not guaranteed to work because the alignment requirements
for a 'char' array and 'SomeType' can be different. To perform
proper placement new, your storage has to be allocated in free
store itself or other measures have to be taken (implementation-
specific, usually) to ensure proper alignment.

Why were you calling the destructor of 'str' yourself, anyway?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
invalid address alignment ADS7328 C++ 2 05-22-2007 08:11 PM
HPUX Invalid Address Alignment when assigning double, casting to same type works? Jay Hamilton C++ 1 08-11-2006 03:32 PM
Re: signal BUS (invalid address alignment) Mike Wahler C++ 2 08-22-2003 02:23 PM
Re: signal BUS (invalid address alignment) Ron Natalie C++ 3 08-21-2003 05:05 PM
Re: signal BUS (invalid address alignment) Artie Gold C++ 0 08-21-2003 03:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57