segmentation-fault

printf command causing a seg fault? [duplicate]

我的梦境 提交于 2019-12-12 18:00:46
问题 This question already has answers here : Getting a stack overflow exception when declaring a large array (9 answers) Closed 6 years ago . When I try to initialize a large double dimensional character array, it works perfectly fine. But when I add a simple print command, it gives me a segmentation fault. Any ideas as to why this is happening? #include<stdio.h> int main(void) { printf("!"); char f[10000][10000]; } It works fine without the printf command, or even if the printf command prints

how to debug using “*.stackdump” file in cygwin

╄→尐↘猪︶ㄣ 提交于 2019-12-12 17:51:26
问题 I am newbie on cygwin(and linux). When I tried to run my executable file based on C language, segmentation fault occured, and I take stackdump file. but, I don't know how to use it for debugging. I have been searching for the way how to debug using stackdump file, but I cound't find it. Any small tips are very useful to me. thanks for reading my poor english (english is not my 1st language). 回答1: First : you need to compile your program passing to gcc the flag -ggdb otherwise the stackdump

Recursive quick-sort causing segmentation fault (not overflow)

故事扮演 提交于 2019-12-12 17:23:41
问题 Please help me (this would be very handy for a school project due tommorow) I haven been trying to implement a recursive quick-sort algorithm in C++, however, when i run it i get a runtime segmentation fault(windows): #include <iostream> #include <sstream> #include <stdlib.h> using namespace std; void getRandomList(int, int*); void outputList(int, int*); void quicksort(int, int*); int main() { cout<<"Quick Sort example, By Jack Wilkie\n"; while (true) { cout<<"Please enter list length\n";

How to understand EXC_BAC_ACCESS (SIGSEGV) KERN_INVALID_ADDRESS log?

家住魔仙堡 提交于 2019-12-12 14:27:13
问题 I'm doing an app in Titanium for Android and IOS. When I navigate a lot in the application I have a random exception and the app crashes. How can I know where is the problem? The app is a little complex to explain: It has two windows, first window is for "home" view that is only in portrait mode, and when I click to go to another view, I close the first window, I open another window and I add a view with the content to this window. The content view load the same web view with different url.

Debugging a clobbered static variable in C (gdb broken?)

雨燕双飞 提交于 2019-12-12 13:15:39
问题 I've done a lot of programming but not much in C, and I need advice on debugging. I have a static variable (file scope) that is being clobbered after about 10-100 seconds of execution of a multithreaded program (using pthreads on OS X 10.4). My code looks something like this: static float some_values[SIZE]; static int * addr; addr points to valid memory address for a while, and then gets clobbered with some value (sometimes 0, sometimes nonzero), thereby causing a segfault when dereferenced.

Segmentation fault within segmentation fault handler

大兔子大兔子 提交于 2019-12-12 11:56:05
问题 Is there some defined behaviour for segmentation faults which happen within segmentation falut handler under Linux? Will be there another call to the same handler? If so, on all platforms, is it defined and so on. Thank you. 回答1: Than answer depends on how you installed your signal handler. If you installed your signal handler using the deprecated signal() call, then it will either reset the signal handler to the default handler or block the signal being handled before calling your signal

Using `foreign import prim` with a C function using STG calling convention

此生再无相见时 提交于 2019-12-12 11:27:44
问题 I have a simple C routine that takes four words and returns four words, and for which gcc can optimize and emit some primops that GHC doesn't support. I'm trying to benchmark various ways of calling this procedure, and am having trouble trying to adapt the technique described here to use foreign import prim . The following is meant to just add 1 to each input word, but segfaults. Main.hs: {-# LANGUAGE GHCForeignImportPrim #-} {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE MagicHash #-

What are some good methods or steps to debug a segmentation fault in Perl?

心不动则不痛 提交于 2019-12-12 11:18:33
问题 There are two cases where my code won't cause a segmentation fault: When I use Smart::Comments in at least one place Run through the debugger. I've tracked it down to this call: $action->{breakdown} = join( ' ' , each_pair { my ( $name, $length ) = @_; return "x$length" if $name eq 'FILLER'; push @$field_list_ref, $name; return "A$length"; } @$field_def_ref ); where each_pair is defined in another module as: sub each_pair (&@) { my $block = shift; return unless @_; my $caller = caller(); my

Rust: Segfault when executing specific line of code from a dynamically loaded library

微笑、不失礼 提交于 2019-12-12 11:12:59
问题 Im writing a simple plugin-based system in Rust to gain some skills and experience using the language. My system dynamically loads libraries and executes them at runtime to initialize each plugin. Im running into an interesting segfault issue when executing code from a dynamically-loaded library. This is the code to load and run the plugin init function: (this bit works fine) pub fn register_plugins<'rp>(&'rp mut self) { let p1 = match DynamicLibrary::open(Some("librust_plugin_1.so")) { Ok

qsort segfault in C

人盡茶涼 提交于 2019-12-12 10:17:41
问题 I'm trying to use qsort in accordance with the man page but regardless of what I try I keep getting a segfault Here's the section of code that matters int compare_dirent(const void *a, const void *b) { const struct dirent *first = (const struct dirent *) a; const struct dirent *second = (const struct dirent *) b; return first->d_ino - second->d_ino; } int process(FILE* output,const char *dirname, int flags) { struct dirent *entries = NULL; struct dirent *table[256]; int entry_num = 0; DIR