Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to fix misaligned assignment statements in the source
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on Sparc
View previous topic :: View next topic  
Author Message
biggyL
Tux's lil' helper
Tux's lil' helper


Joined: 31 Jan 2005
Posts: 120
Location: Israel

PostPosted: Thu May 25, 2006 10:09 am    Post subject: How to fix misaligned assignment statements in the source Reply with quote

Hello All,

I'm fighting to install Darwin Streaming Server on "Gentoo on Sparc".

I've started to dig for the "Bus error" error on sparc64 architecture I get in time QT player tries to connect to DSS, while running DSS in debug mode: /usr/local/sbin/DarwinStreamingServer -c /etc/streaming/streamingserver.xml -d -S 60

And found that "64-bit assignment statements tend to cause bus errors if misaligned"
(look here: http://mail-index.netbsd.org/netbsd-bugs/1997/11/13/0001.html
And here: http://mail.gnome.org/archives/gamin-list/2005-August/msg00111.html)

So now I got to figure out what to change in source code before I compile it and try again.

Here is the example of resolution for this kind of problem on another project (a snap from the .diff):
Code:

@@ -499,8 +499,11 @@
         conn->request_len -= req->len;
         if (conn->request_len == 0)
             break;
-
+#if defined (__i386__)
 req = (void *) req + req->len;
+#else
+memmove(&conn->request, (void *)req + req->len, conn->request_len);
+#endif
     }
 
     if (conn->request_len > 0 && req != &conn->request)


I'm not a C/C++ programmer, but I've found this:
Quote:

"The "bus error" signal usually means a data access was not properly aligned. It is always due to an error in the program.

One major cause is accessing data via a pointer of a different type that has different alignment requirements. Example:

short s[2]; // 2-byte alignment
int* p = (int*)s; // pretend the 2 shorts are one int
int i = *p; // bus error is likely

On SPARC, an int must be aligned on a 4-byte boundary, but a short only needs 2-byte alignment. The attempted load fails with a bus error if array s was not 4-byte aligned.

The other major cause is due to using invalid pointers. For example, dereferencing a pointer that was not initialized, or that points to data that no longer exists. The bus error usually far in space and time from the point of the error. These errors are hard to find."


Below are compilation warnings I get while compiling on Sparc64:
Code:

StrPtrLen.cpp: In member function `Bool16 StrPtrLen::NumEqualIgnoreCase(const char*, UInt32) const':
StrPtrLen.cpp:143: warning: array subscript has type `char'
StrPtrLen.cpp:143: warning: array subscript has type `char'
StrPtrLen.cpp: In member function `Bool16 StrPtrLen::EqualIgnoreCase(const char*, UInt32) const':
StrPtrLen.cpp:156: warning: array subscript has type `char'
StrPtrLen.cpp:156: warning: array subscript has type `char'
StrPtrLen.cpp: In member function `void StrPtrLen::PrintStr()':
StrPtrLen.cpp:306: warning: array subscript has type `char'
StrPtrLen.cpp: In member function `void StrPtrLen::PrintStrEOL(char*, char*)':
StrPtrLen.cpp:336: warning: array subscript has type `char'
UDPSocketPool.cpp: In member function `UDPSocketPair* UDPSocketPool::CreateUDPSocketPair(UInt32, UInt16)':
UDPSocketPool.cpp:112: warning: comparison is always true due to limited range of data type
In file included from SDPUtils.cpp:26:
SDPUtils.h: In member function `Bool16 SDPContainer::HasLineType(char)':
SDPUtils.h:92: warning: array subscript has type `char'
SDPUtils.cpp: In member function `void SDPContainer::Parse()':
SDPUtils.cpp:137: warning: array subscript has type `char'
ar: creating libCommonUtilitiesLib.a
ar: creating libQTFileLib.a
ar: creating libQTFileExternalLib.a
Server.tproj/QTSSDataConverter.cpp: In static member function `static QTSS_Error QTSSDataConverter::ConvertCHexStringToBytes(char*, void*, UInt32*)':
Server.tproj/QTSSDataConverter.cpp:270: warning: array subscript has type `char'
Server.tproj/QTSSDataConverter.cpp:272: warning: array subscript has type `char'
In file included from APICommonCode/SDPSourceInfo.cpp:40:
CommonUtilitiesLib/SDPUtils.h: In member function `Bool16 SDPContainer::HasLineType(char)':
CommonUtilitiesLib/SDPUtils.h:92: warning: array subscript has type `char'
In file included from APIModules/QTSSFileModule/QTSSFileModule.cpp:48:
CommonUtilitiesLib/SDPUtils.h: In member function `Bool16 SDPContainer::HasLineType(char)':
CommonUtilitiesLib/SDPUtils.h:92: warning: array subscript has type `char'
In file included from APIModules/QTSSReflectorModule/QTSSReflectorModule.cpp:59:
CommonUtilitiesLib/SDPUtils.h: In member function `Bool16 SDPContainer::HasLineType(char)':
CommonUtilitiesLib/SDPUtils.h:92: warning: array subscript has type `char'
APIModules/QTSSReflectorModule/QTSSReflectorModule.cpp: In function `void DoAnnounceAddRequiredSDPLines(QTSS_StandardRTSP_Params*, ResizeableStringFormatter*, char*)':
APIModules/QTSSReflectorModule/QTSSReflectorModule.cpp:847: warning: array subscript has type `char'
In file included from APIModules/QTSSReflectorModule/RTSPSourceInfo.cpp:42:
CommonUtilitiesLib/SDPUtils.h: In member function `Bool16 SDPContainer::HasLineType(char)':
CommonUtilitiesLib/SDPUtils.h:92: warning: array subscript has type `char'
/usr/lib/gcc/sparc-unknown-linux-gnu/3.4.6/../../../../sparc-unknown-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object.
/usr/lib/gcc/sparc-unknown-linux-gnu/3.4.6/../../../../sparc-unknown-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object.
/usr/lib/gcc/sparc-unknown-linux-gnu/3.4.6/../../../../sparc-unknown-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object.
/usr/lib/gcc/sparc-unknown-linux-gnu/3.4.6/../../../../sparc-unknown-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object.
/usr/lib/gcc/sparc-unknown-linux-gnu/3.4.6/../../../../sparc-unknown-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object.
proxy.c: In function `sig_catcher':
proxy.c:177: warning: implicit declaration of function `sigignore'
QTSSPasswd.cpp:422: warning: 'char* SetTempPath(char*, int, char*, int, char)' defined but not used
In file included from playlist_SDPGen.cpp:31:
../CommonUtilitiesLib/SDPUtils.h: In member function `Bool16 SDPContainer::HasLineType(char)':
../CommonUtilitiesLib/SDPUtils.h:92: warning: array subscript has type `char'
In file included from BroadcasterSession.cpp:38:
../CommonUtilitiesLib/SDPUtils.h: In member function `Bool16 SDPContainer::HasLineType(char)':
../CommonUtilitiesLib/SDPUtils.h:92: warning: array subscript has type `char'


Any Help/Ideas Please.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on Sparc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum