segmentation-fault

Segmentation fault on boost::multi_array

旧时模样 提交于 2019-12-20 05:29:29
问题 The following code gives a segmentation fault: #include <iostream> #include <fstream> #include "binItr.h" #include <boost/multi_array.hpp> using namespace std; int main(){ const char * xifile = "results/feretxiG1155V0P5T231K10.bin"; const uint pSize = 5; const uint T = 231; ifstream xiFileId(xifile, ios::binary); typedef boost::multi_array<uint, 2> array_type; array_type xi(boost::extents[T][pSize + 1]); //the ii_t class in the following line is taken from http://stackoverflow.com/questions

Segmentation fault on boost::multi_array

大憨熊 提交于 2019-12-20 05:29:09
问题 The following code gives a segmentation fault: #include <iostream> #include <fstream> #include "binItr.h" #include <boost/multi_array.hpp> using namespace std; int main(){ const char * xifile = "results/feretxiG1155V0P5T231K10.bin"; const uint pSize = 5; const uint T = 231; ifstream xiFileId(xifile, ios::binary); typedef boost::multi_array<uint, 2> array_type; array_type xi(boost::extents[T][pSize + 1]); //the ii_t class in the following line is taken from http://stackoverflow.com/questions

Customizing CGAL Kernel with my own Point class

亡梦爱人 提交于 2019-12-20 05:21:27
问题 I would like to use a custom Point class with the CGAL constrained delaunay triangulation. However, with the following MyPoint class (which should behave the exact same as a CGAL::Point_2 no?) I get segmentation faults. It works perfectly if I set the Point_2 typedef inside MyKernel to CGAL::Exact_predicates_inexact_constructions_kernel::Point_2. What am I doing wrong? template<class P> struct MyPoint : public P { MyPoint() : P() {} MyPoint(const MyPoint& p) : P(p) {} MyPoint( int x, int y) :

Customizing CGAL Kernel with my own Point class

末鹿安然 提交于 2019-12-20 05:21:22
问题 I would like to use a custom Point class with the CGAL constrained delaunay triangulation. However, with the following MyPoint class (which should behave the exact same as a CGAL::Point_2 no?) I get segmentation faults. It works perfectly if I set the Point_2 typedef inside MyKernel to CGAL::Exact_predicates_inexact_constructions_kernel::Point_2. What am I doing wrong? template<class P> struct MyPoint : public P { MyPoint() : P() {} MyPoint(const MyPoint& p) : P(p) {} MyPoint( int x, int y) :

Boost::filesystem, std::sort: trouble retaining information on sort passes

不想你离开。 提交于 2019-12-20 05:16:54
问题 I'm trying to use std::sort on a data type that contains information read from a boost::filesystem::dictionary_iterator . It appears that as the sorting algorithm has done n comparisons, n being the number of files in the directory, that information gets lost and I end up segfaulting. Valgrind says I'm using uninitialized values and doing invalid reads. How can I change my File data type or algorithms so that the information is kept between passes? #include <iostream> #include <algorithm>

Multithreaded program segfaults with OpenSSL and OpenMP

倾然丶 夕夏残阳落幕 提交于 2019-12-20 04:31:16
问题 I am using OpenSSL in a multithreaded program in C and having issues. So I wrote a small program to try to narrow down what the problem is. The functions besides the main function were copy pasted from https://github.com/plenluno/openssl/blob/master/openssl/crypto/threads/mttest.c My program is as follows. #include<stdio.h> #include<stdlib.h> #include<stdarg.h> #include <strings.h> #include <string.h> #include <math.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include<omp

Segmentation fault depending on string length?

十年热恋 提交于 2019-12-20 03:50:47
问题 I am writing a program that will read lines from an infile using getline into strings, convert the strings to c-strings containing the first m nonwhitespace characters of the string, then concatenate the c-strings into a single char array. A sample file might look something like this: 5 //number of rows and columns in a grid 2 //number of grids XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX So I'd end up with a char array of 2x5x5 characters. Now the problem is my code works fine

pointer to a vector element crashes

只愿长相守 提交于 2019-12-20 03:37:41
问题 vector<int> v; v.push_back(1); int * p = &v[0]; for (int i = 2; i <= 100; ++i) { v.push_back(i); } *p = 5; I know vector reallocated new piece of memory to increase capacity, but p is just a pointer to some memory address and p itself didn't change. Also memory pointed to by p is in the address space of the same process even after the vector reallocates. Why would it crash? 回答1: If you change your code to the following: #include <stdio.h> #include <vector> int main(int argc, char* argv[]) {

cython segmentation fault handling

笑着哭i 提交于 2019-12-20 02:38:46
问题 I am wrapping some C library, and I have one function which in some cases may result with segmentation fault. In that case I need to call second function, which will in that situation complete successfully. Does anyone knows how can I handle segmentation fault in cython? 回答1: A short example that might help (using signal ): example.h (assuming the Cython extension is named myext.pyx ) // Header autogenerated by Cython when declaring "public api" functions #include "../myext_api.h" void

Seg Fault when using std::string on an embedded Linux platform

主宰稳场 提交于 2019-12-19 08:13:00
问题 I have been working for a couple of days on a problem with my application running on an embedded Arm Linux platform. Unfortunately the platform precludes me from using any of the usual useful tools for finding the exact issue. When the same code is run on the PC running Linux, I get no such error. In the sample below, I can reliably reproduce the problem by uncommenting the string, list or vector lines. Leaving them commented results in the application running to completion. I expect that