segmentation-fault

What is a canonical way to produce a segmentation fault in C#?

放肆的年华 提交于 2019-12-10 14:48:43
问题 I am interested in the shortest, neatest piece of C# code around that will reliably produce a segfault - ideally without directly calling any unmanaged code. 回答1: What you're after is somewhat unclear but I suppose this is as good as any answer so far, and it is about as minimal as you can get. System.Runtime.InteropServices.Marshal.ReadInt32(IntPtr.Zero); 回答2: Michael's answer wasn't working for me, perhaps that case is caught now. Marshal.ReadInt32() just gives me a "SystemError: Attempted

Why does MPI_Barrier cause a segmentation fault in C++

筅森魡賤 提交于 2019-12-10 14:42:17
问题 I have reduced my program to the following example: #include <mpi.h> int main(int argc, char * argv[]) { int rank, size; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); return 0; } I compile and run the code, and get the following result: My-MacBook-Pro-2:xCode_TrapSim user$ mpicxx -g -O0 -Wall barrierTest.cpp -o barrierTestExec My-MacBook-Pro-2:xCode_TrapSim user$ mpiexec -n 2 ./barrierTestExec =

Why Do I Get This Segmentation Fault In This PHP Command Line Script?

≯℡__Kan透↙ 提交于 2019-12-10 13:56:17
问题 It's just a quick script to a message to what I call a 'mental log file'. Just to keep track of my thoughts when I drift off and get myself back to work. Anyway, it works alright most of the time, but every so often I get a segmentation fault. Heard of them in C, but never had them before in PHP. Here's the script: #!/usr/bin/php <?php $mental_log_file = "/home/ali/mental-log"; array_shift($argv); //get rid of the initial arg (name of the command) $log_entry = date('j-n-y H:i') . ' ' .

python package compiled with nuitka fails with segmentation fault

不羁的心 提交于 2019-12-10 12:12:31
问题 I'm developing an embedded device controlled by a python2.7 script. And I need to compile the source for both security (I don't want device users to mess with my sources) and performance (I'm working on an BeagleBone Black, ARM microPC, and it's pretty short on CPU/RAM). I'm using Nuitka python compiler for this. I've tried compiling separate modules of my application and it works fine, I can transparently replace random .py with it's compiled .so analogue and it all works fine. Yet if I try

Segmentation fault occurs at top of subroutine when C code calls Fortran subroutine

烂漫一生 提交于 2019-12-10 11:56:46
问题 I have C++ code in file test-Q.cpp that calls a Fortran subroutine in file getqpf.F . In file test-Q.cpp , I've declared the Fortran code as external, and I am calling the function using the getqpf_() name-mangling convention. The gcc and gfortran compilers are being used on GNU/Linux. Here is a snippet from the top of the C++ file: extern "C" { void getqpf_ (double *tri, int nsamp, int lwin, int nfreqfit, double dt, float null, int L2, double df, double *qq, double *pf, double *ampls, double

C++ Array Allocation Segmentation Fault 11 Newbie

心不动则不痛 提交于 2019-12-10 11:45:04
问题 I am learning C++ from Algorithms in C++ by Robert Sedgewick. Right now I am working on the Sieve of Eratosthenes with a user specified upper bound on the largest prime. When I run the code with max 46349, it runs and prints out all primes up to 46349, however when I run the code with max 46350, a Segmentation fault occurs. Can someone help to explain why? ./sieve.exe 46349 2 3 5 7 11 13 17 19 23 29 31 ... ./sieve.exe 46350 Segmentation fault: 11 Code: #include<iostream> using namespace std;

Mex dynamic memory management issue with std::vector in linked external DLL; Segmentation error

浪尽此生 提交于 2019-12-10 11:44:15
问题 I am trying to create a mex file that interfaces MATLAB with an external C++ library that communicates with some hardware. An imported library and precompiled DLL (.lib and .dll) are provided by the hardware vendor for my version of VC++ and I was able to implement them in C++ without any issue. However, I ran into segmentation error at run time when the code is written as a mex(compiled with the same version of VC++). After some investigation with the VC++ debugger, the likely culprit seems

Reading a file using fgets and printing its content on screen

这一生的挚爱 提交于 2019-12-10 11:15:14
问题 I still consider myself as a new webby in C.I am trying to read a file in, file is not binary but its size varies from small size of feb kbs to big size files of feb Mbs.I am using fgets function, i had taken reference from this link but after compilation, i am getting segmentation fault.i tried to debug it with gdb and found that i am able to open file but unable to read.Here is my code. #include<stdio.h> #define MAX_LENGTH 1048576 int main() { FILE *fp; char *result; char line[MAX_LENGTH];

Segmentation Fault executing pm on android

点点圈 提交于 2019-12-10 11:13:32
问题 I am able to execute pm from the adb shell fine, but I get a segmentation fault if I try and execute it from the terminal. I have read this thread which suggests a similar problem, but their solution doesn't seem to work. The stack trace is as follows: 01-22 04:04:39.356: D/AndroidRuntime(5059): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 01-22 04:04:39.356: D/AndroidRuntime(5059): CheckJNI is OFF 01-22 04:04:39.366: I/dalvikvm(5059): DexOpt: Some deps went away 01

Get a segment fault while reading a file

末鹿安然 提交于 2019-12-10 10:46:51
问题 I want to read the whole file content and print it out , but I get a segment fault , I can't find what's wrong with the code ... #include <stdio.h> #include <stdlib.h> int main() { FILE * file; long fsize; file = fopen("./input.txt","r"); if(file != NULL){ //get file size fseek(file,0,SEEK_END); fsize = ftell(file); rewind(file); // print char * file_content; fgets(file_content,fsize,file); puts(file_content); } else{ printf("open failure\n"); } fclose(file); return 0; } 回答1: The pointer you