Home > gcc solaris > gcc solaris bus error

Gcc Solaris Bus Error

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Solaris de-referencing bus error up vote 0 down vote favorite I have a function where I'm trying to take a 16-bit from a large chunk of data. I'm running this code on a Solaris box and I can compile without warning or error. When I run this code, however, whenever it gets to the part where I de-deference my pointer, I instantly get a bus error. The code looks something like: void find_info(unsigned char* packet) { int offset = 9; uint16_t short_value = *(uint16_t*)(packet+offset); } The bus error occurs when I'm trying to de-reference that "packet+offset" pointer in order to get a short. I know for a fact there is data at packet[offset] and packet[offset+1]. On Linux and Cygwin this code works fine. As far as I know, I'm not doing anything revolutionary. What's going on here? pointers casting solaris share|improve this question asked Jun 15 '11 at 12:48 Poff 8429 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted Sounds like an alignment problem. On the Sun SPARC processor, you can only access something like a short via a pointer that is divisible by some power of 2, typically 8. So the value of offset=9 is clearly going to cause a problem. See http://blogs.oracle.com/d/entry/on_misaligned_memory_accesses for more details. I can't recommend any way of fixing this without seeing more context; but if you're reading data from some input source, you could just read the bytes and convert to a short using ntohs (see the man page for ntohs for details). share|improve this answer answered Jun 15 '11 at 13:15 chrisdowney 989617 Very interesting. I'm going to have to experim

Java, SQL, and other programming languages here. Search Forums Show Threads Show Posts Tag Search Advanced Search Unanswered Threads Find All Thanked Posts Go to Page... unix and linux operating commands Solaris - BUS error with optimize mode Programming Page 1 of 3 1 23 > Thread Tools Search this Thread Display Modes #1 05-08-2015 revolta25 Registered User Join Date: Jan 2015 Last Activity: 8 May 2015, 2:13 PM EDT Posts: 6 Thanks: 0 Thanked 0 Times http://stackoverflow.com/questions/6357884/solaris-de-referencing-bus-error in 0 Posts Solaris - BUS error with optimize mode Hi, I'm facing BUS (invalid address alignment) issue. Application works correctly with binaries compiled without optimization. When "-O3" (or -O2, O1) is in use, application abort with - BUS (invalid address alignment). The problem appears in following situation: Code: struct _a { int _a1; uint64_t _a2; } int f2(uint64_t *obj) { printf("%llu", *obj); <--- http://www.unix.com/programming/257691-solaris-bus-error-optimize-mode.html BUS ERROR return 0; } void f1() { ... _a* obj_a = malloc(); printf("%llu", obj_a->_a2); <--- OK f2(&obj_a->_a2); } Solaris Sparc GCC 4.2.1 Thanks Remove advertisements Sponsored Links revolta25 View Public Profile Find all posts by revolta25 #2 05-08-2015 Corona688 Mead Rotor Join Date: Aug 2005 Last Activity: 14 October 2016, 6:51 PM EDT Location: Saskatchewan Posts: 21,548 Thanks: 997 Thanked 3,955 Times in 3,676 Posts Is that really the entire code? Does it still cause that crash when minimized like that? Remove advertisements Sponsored Links Corona688 View Public Profile Visit Corona688's homepage! Find all posts by Corona688 #3 05-08-2015 revolta25 Registered User Join Date: Jan 2015 Last Activity: 8 May 2015, 2:13 PM EDT Posts: 6 Thanks: 0 Thanked 0 Times in 0 Posts Thanks form the reply. No, it's just an example. It's a big system so it's hard to present problem detailed. For some reason, when object from struct is passed by reference to function and we want to manipulate by pointer on this object it cause BUS error. With test function with param "struct

[x] User account creation filtered due to spam. Bug12364 - "internal compiler error: Bus Error" in gcc 3.3.1 on Solaris 8 Summary: "internal compiler https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12364 error: Bus Error" in gcc 3.3.1 on Solaris 8 Status: RESOLVED WORKSFORME Alias: None Product: gcc Classification: Unclassified Component: c (show other bugs) Version: 3.3.1 Importance: P2 normal Target Milestone: --- Assignee: Not yet https://github.com/the-tcpdump-group/tcpdump/issues/130 assigned to anyone URL: Keywords: Depends on: Blocks: Reported: 2003-09-22 07:43 UTC by Kristian Wiklund Modified: 2005-07-23 22:49 UTC (History) CC List: 1 user (show) gcc-bugs See Also: Host: Target: Build: Known gcc solaris to work: Known to fail: Last reconfirmed: Attachments Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Description Kristian Wiklund 2003-09-22 07:43:36 UTC * Host system: sparc-sun-solaris2.8 * Target system: sparc-sun-solaris2.8 * gcc version: Reading specs from /app/gcc/3.3.1/lib/gcc-lib/sparc-sun- solaris2.8/3.3.1/specs Configured with: ../gcc-3.3.1/configure --prefix=/app/gcc/3.3.1 --with-gnu- as --with-as=/app/binutils/2.13.2.1/bin/as --with-gnu-ld --with- ld=/app/binutils/2.13.2.1/bin/ld Thread model: posix gcc solaris bus gcc version 3.3.1 * Compiler output: syntaxtree.c: In function `make_tips': syntaxtree.c:23: warning: assignment makes pointer from integer without a cast syntaxtree.c:21: internal compiler error: Bus Error * How to reproduce: gcc apa.i * Preprocessed file "apa.i" # 1 "syntaxtree.c" # 1 "" # 1 "" # 1 "syntaxtree.c" # 1 "syntaxtree.h" 1 # 9 "syntaxtree.h" # 1 "list.h" 1 # 11 "list.h" struct list { struct listitem *start, *end; int nr; struct listitem *iterator; char *fun; int line; }; typedef struct list *list; struct listitem { void *data; struct listitem *n; }; # 10 "syntaxtree.h" 2 struct yyltype {int i; }; struct tips { char *tips_kind; int prodcnt; struct yyltype yyl; char *filename; int type; }; struct tips *make_tips(int type); typedef enum {type_ERROR = 0, type_SCALAR, type_STRUCT, type_ARRAY} type_type; struct Type { char *tips_kind; int prodcnt; struct yyltype yyl; char *filename; type_type type; int size; int alignment; char *name; }; struct Type *make_Type(char *name); struct type_scalar { char *tips_kind; int prodcnt; struct yyltype yyl; char *filename; type_type type; int size; int alignment; char *name; }; struct type_scalar *make_type_scalar(char *name); struct type_struct { char *tips_kind; int prodcnt; struct yyltype yyl; char *filename; type_type type; int size; int alignment; int tailpad

Sign in Pricing Blog Support Search GitHub This repository Watch 62 Star 415 Fork 265 the-tcpdump-group/tcpdump Code Issues 44 Pull requests 11 Projects 0 Pulse Graphs New issue tcpdump 4.1.1 bus error when 'gcc -O2' (default) optimizatio #130 Closed guyharris opened this Issue Apr 16, 2013 · 4 comments Projects None yet Labels found in 4.1 Milestone No milestone Assignees No one assigned 1 participant The Tcpdump Group member guyharris commented Apr 16, 2013 Converted from SourceForge issue 3042751, submitted by itillman Platform: tcpdump 4.1.1 libpcap 1.1.1 Solaris 10 gcc 4.2.4 (Also verified with gcc 3.3.6 on Solaris 9, gcc 4.1.2 on on Solaris 9, gcc 4.3.4 on Solaris 10, gcc 4.4.3 on Solaris 10 tcpdump 4.1.1 built with gcc 4.2.4 on Solaris 10 (defaults to 'gcc -O2'): % /var/local/src/tcpdump-4.1.1/tcpdump -r sample.pcap -ne reading from file sample.pcap, link-type EN10MB (Ethernet) Bus Error (core dumped) Adding -q makes the problem go away: % /var/local/src/tcpdump-4.1.1/tcpdump -r sample.pcap -neq reading from file sample.pcap, link-type EN10MB (Ethernet) 14:24:55.977040 04:1e:64:d7:92:e0 > 00:06:2a:db:a0:c0, 802.1Q, length 346: vlan 2000, p 0, ethertype IPv4, 140.180.46.122.68 > 128.112.128.1.67: UDP, length 300 Rebuild tcpdump adding '-g' to CCOPT in Makefile, so we can debug more easily. Crashes as expected: % /var/local/src/tcpdump-4.1.1/tcpdump -r sample.pcap -ne reading from file sample.pcap, link-type EN10MB (Ethernet) Bus Error (core dumped) % gdb /var/local/src/tcpdump-4.1.1/tcpdump ./core GNU gdb (GDB) 7.0 Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change

 

Related content

No related pages.