bus-error

Retrieving memory data with non-canonical-address causes SIGSEGV rather than SIGBUS

妖精的绣舞 提交于 2021-01-27 18:46:36
问题 I can not produce a "Bus error" with the following assembly code. Here the memory address I use is not a legal "canonical-address". So, how can I trigger that error? I was running this snippet of code under Ubuntu 20.04 LTS with NASM 2.14.02, but it results in a SIGSEGV segmentation fault on the load, not SIGBUS. global _start section .text _start: mov rax, [qword 0x11223344557788] mov rax, 60 xor rdi, rdi syscall Corresponding X86-64 assembly code after compiling: Disassembly of section

Bus error with allocated memory on a heap

一曲冷凌霜 提交于 2020-01-22 02:22:10
问题 I have Bus Error in such code: char* mem_original; int int_var = 987411; mem_original = new char [250]; memcpy(&mem_original[250-sizeof(int)], &int_var, sizeof(int)); ... const unsigned char* mem_u_const = (unsigned char*)mem_original; ... const unsigned char *location = mem_u_const + 250 - sizeof(int); std::cout << "sizeof(int) = " << sizeof(int) << std::endl;//it's printed out as 4 std::cout << "byte 0 = " << int(*location) << std::endl; std::cout << "byte 1 = " << int(*(location+1)) << std

C++ Bus error in SPARC arcitecture

烂漫一生 提交于 2020-01-13 07:17:11
问题 I would like to understand why I am getting a bus error with this code. int main() { int p=34; int *pp= (int *) ((char *)&p+1); cout<<*pp<<"\n"; return 0; } 回答1: It will no doubt be an alignment issue. On many architectures, certain types have to be aligned properly, an example being that 4-byte integers must start on a 4-byte boundary. If you access non-aligned data, some architectures won't care, others will run slower, still others (such as in this case) will fall in a screaming heap. When

Dereferencing function pointers in C to access CODE memory

谁都会走 提交于 2020-01-11 02:16:33
问题 We are dealing with C here. I'm just had this idea, wondering if it is possible to access the point in memory where a function is stored, say foo and copying the contents of the function to another point in memory. Specifically, I'm trying to get the following to work: #include <stdlib.h> #include <stdio.h> #include <string.h> void foo(){ printf("Hello World"); } int main(){ void (*bar)(void) = malloc(sizeof foo); memcpy(&bar, &foo, sizeof foo); bar(); return 0; } But running it gives a bus

Xcode Bus Error When Compiling

你离开我真会死。 提交于 2019-12-12 06:24:55
问题 My iPhone app was compiling just fine, then all of the sudden, it started failing to compile, with the error: LLVM GCC 4.2 Error Internal Compiling Error: Bus Error 10 It compiles just fine for the simulator but it won't build to a device. I have tried what seems like everything, and nothing works. There is no stack trace that I can post. Additionally, the code is too long to paste all of it here since I can't be sure exactly where the problem is (again, no stack trace). How can I narrow this

R ffdfappend SIGBUS error

你说的曾经没有我的故事 提交于 2019-12-11 03:59:06
问题 I have an R script which uses the ffbase and ff packages. In Windows the script runs fine. In Linux (different box, higher RAM though) it crashes with a bus (SIGBUS) error. Windows (Version 6.1.7601) session info: R version 3.1.0 (2014-04-10) Platform: x86_64-w64-mingw32/x64 (64-bit) attached packages: ffbase_0.11.3 ff_2.2-13 bit_1.1-12 Linux (Linux xenja 3.5.0-54-generic #81~precise1-Ubuntu SMP Tue Jul 15 04:02:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux) session info: R version 3.1.1 (2014

How to get a “bus error”?

浪尽此生 提交于 2019-12-09 02:23:18
问题 I am trying very hard to get a bus error. One way is misaligned access and I have tried the examples given here and here, but no error for me - the programs execute just fine. Is there some situation which is sure to produce a bus error? 回答1: Bus errors can only be invoked on hardware platforms that: Require aligned access, and Don't compensate for an unaligned access by performing two aligned accesses and combining the results. You probably do not have access to such a system. 回答2: This

Why does the following C program give a bus error?

旧街凉风 提交于 2019-12-06 02:49:10
问题 I think it's the very first strtok call that's failing. It's been a while since I've written C and I'm at a loss. Thanks very much. #include <stdio.h> #include <string.h> int main(int argc, char **argv) { char *str = "one|two|three"; char *tok = strtok(str, "|"); while (tok != NULL) { printf("%s\n", tok); tok = strtok(NULL, "|"); } return 0; } 回答1: String literals should be assigned to a const char*, as modifying them is undefined behaviour. I'm pretty sure that strtok modifies it's argument,

Why does the following C program give a bus error?

て烟熏妆下的殇ゞ 提交于 2019-12-04 05:42:27
I think it's the very first strtok call that's failing. It's been a while since I've written C and I'm at a loss. Thanks very much. #include <stdio.h> #include <string.h> int main(int argc, char **argv) { char *str = "one|two|three"; char *tok = strtok(str, "|"); while (tok != NULL) { printf("%s\n", tok); tok = strtok(NULL, "|"); } return 0; } String literals should be assigned to a const char*, as modifying them is undefined behaviour. I'm pretty sure that strtok modifies it's argument, which would explain the bad things that you see. There are 2 problems: Make str of type char[] . GCC gives

Bus error with allocated memory on a heap

我怕爱的太早我们不能终老 提交于 2019-12-02 12:36:17
I have Bus Error in such code: char* mem_original; int int_var = 987411; mem_original = new char [250]; memcpy(&mem_original[250-sizeof(int)], &int_var, sizeof(int)); ... const unsigned char* mem_u_const = (unsigned char*)mem_original; ... const unsigned char *location = mem_u_const + 250 - sizeof(int); std::cout << "sizeof(int) = " << sizeof(int) << std::endl;//it's printed out as 4 std::cout << "byte 0 = " << int(*location) << std::endl; std::cout << "byte 1 = " << int(*(location+1)) << std::endl; std::cout << "byte 2 = " << int(*(location+2)) << std::endl; std::cout << "byte 3 = " << int(*