segmentation-fault

Nasm - Symbol `printf' causes overflow in R_X86_64_PC32 relocation

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 01:56:34
I am trying to create a simple program in nasm that should display the letter a . however, It is giving me a Segfault and saying this: ./a.out: Symbol `printf' causes overflow in R_X86_64_PC32 relocation Segmentation fault (core dumped) Basically, I am trying to move the value 0x61 (hex for letter a) into memory address 1234, and then pass that as an argument to printf. Here is my exact code: extern printf section .text global main main: push rbp mov rax,0 mov qword [1234], 0x61 ; move 0x61 into address 1234 mov rdi, qword [1234] ; mov address 1234 into rdi call printf ; should print the

graphviz segmentation fault

不问归期 提交于 2019-12-05 01:40:32
问题 I'm building a graph with many nodes, around 3000. I wrote a simple python program to do the trick with graphviz, but it gives me segmentation fault and I don't know why, if the graph is too big or if i'm missing something. The code is: #!/usr/bin/env python # Import graphviz import sys sys.path.append('..') sys.path.append('/usr/lib/graphviz') import gv # Import pygraph from pygraph.classes.graph import graph from pygraph.classes.digraph import digraph from pygraph.algorithms.searching

Turning on g++ optimization causes segfault - I don't get it

五迷三道 提交于 2019-12-05 01:40:13
I've been working on my program, and I decided to turn on some optimizations using g++ -O3 . Suddenly, my program started segfaulting. I've hunted the problematic code down, and minimized my program to something that still segfaults (only when using level 3 optimizations). I was hoping someone could take a quick peek at the code (I tried minimizing it as much as possible): // src/main.cpp #include "rt/lights/point.hpp" int main(int argc, char **argv) { rt::Light *light = new rt::light::Point(alg::vector(.0f, 5.0f, 5.0f), rt::Color(1.0f), .5f); return 0; } // include/rt/lights/point.hpp #ifndef

Why is LLVM segfaulting when I try to emit object code?

故事扮演 提交于 2019-12-05 00:59:21
问题 I'm trying to follow along with the LLVM tutorial on compiler implementation, but my code segfaults when I try to emit object code. Here's a minimal example that attempts to compile a function func . To keep things simple, func is a function that does nothing. #include <iostream> #include <llvm/ADT/Optional.h> #include <llvm/IR/BasicBlock.h> #include <llvm/IR/DerivedTypes.h> #include <llvm/IR/Function.h> #include <llvm/IR/IRBuilder.h> #include <llvm/IR/LLVMContext.h> #include <llvm/IR

Meaning of Exit Code 11 in C?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 23:57:13
What's the general meaning of an exit code 11 in C? I've looked around and can not find a definitive answer so I thought I would ask here. It comes when i try to add an element to a vector. Gilles 'SO- stop being evil' You didn't find a definitive answer because there isn't one. It's up to the author of the program to decide what exit codes they wish to use. Standard C only says that exit(0) or exit(EXIT_SUCCESS) indicate that the program is successful, and that exit(EXIT_FAILURE) indicates an error of some kind. (Returning a value from main is equivalent to calling exit with that value.) Most

cv::remap segfaults with std::thread

断了今生、忘了曾经 提交于 2019-12-04 22:52:25
I am getting segfault with the following simple code: #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <iostream> #include <thread> #include <unistd.h> void run() { sleep(1); // see below cv::Mat source(10, 10, CV_32FC1, -1); cv::Mat result(10, 10, CV_32FC1); cv::Mat trX(result.rows, result.cols, CV_32FC1, 5); cv::Mat trY(result.rows, result.cols, CV_32FC1, 5); cv::remap(source, result, trX, trY, cv::INTER_LINEAR, cv::BORDER_TRANSPARENT); std::cout << "done" << std::endl; } int main(int argc, char* argv[]) { std::thread t1(run); t1.join(); std::thread t2

How to fix segmentation fault 11 error? [duplicate]

无人久伴 提交于 2019-12-04 21:40:36
This question already has an answer here : Definitive List of Common Reasons for Segmentation Faults (1 answer) Closed 2 years ago . I want the main returns the position of the occurrences of "mdl" in "dati". I set up the "schema" function to find the starting point of each occurrence, but when i run the program from the command line, it returns: Segmentation fault: 11 I don't know how to fix the problem. Here's the code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int schema(int testo[], int nT, int modello[], int nM, int primo) { int i, j, k; static int r[12]

Using a pointer to a dynamic 2D Array within a struct

夙愿已清 提交于 2019-12-04 20:19:11
I have been writing a piece of code for my coursework in electromagnetic simulation and I have run into a problem. I decided to do a bit extra by expanding the original calculations to really large meshes of up to 10^8 elements, so now I have to use malloc(). So far, so good, but since I prefer to keep my code in libraries and then compile with the inline option of the compiler, I needed a way to pass information between functions. So, I started using structs to keep track of the parameters of the mesh, as well as the pointer to the array of information. I defined the struct the following way:

Executing shellcode stored in environment variable using buffer overflow

不打扰是莪最后的温柔 提交于 2019-12-04 19:18:05
I'm using the code below to try to execute some shellcode stored in an environment variable by overflowing the searchstring variable so that the return address of main contains the address of the anvironment variable. However, I get a segmentation fault before the printf command. #include <stdio.h> #include <string.h> void main(int argc, char *argv[]){ char searchstring[100]; if(argc > 1) strcpy(searchstring, argv[1]); else // otherwise searchstring[0] = 0; printf("Here"); } I compile the code using gcc -m32 -g -o overflow.o overflow.c -fno-stack-protector -z execstack in order to disable the

Segmentation fault (core dumped) Error

强颜欢笑 提交于 2019-12-04 15:24:46
My program compiles fines but upon inputting a file I get a "Segmentation fault (core dumped)" error. Am I not handling the ostream correctly? #include <std_lib_facilities.h> struct Reading { int hour; double temperature; Reading(int h, double t): hour(h), temperature(t) { } bool operator<(const Reading &r) const; }; bool Reading::operator<(const Reading &r) const { // stub version if (temperature < r.temperature){ return true; } else if (r.temperature < temperature) { return false; } } /* * function declarations */ ostream& operator<<(ostream& ost, const Reading &r); vector<Reading> get_temps