segmentation-fault

C segmentation fault before/during return statement

大兔子大兔子 提交于 2019-12-04 07:17:37
I print the value that I'm returning right before my return statement, and tell my code to print the value that was returned right after the function call. However, I get a segmentation fault after my first print statement and before my second (also interesting to note, this always happens on the third time the function is called; never the first or the second, never fourth or later). I tried printing out all of the data that I'm working on to see if the rest of my code was doing something it maybe shouldn't, but my data up to that point looks fine. Here's the function: int findHydrogen(struct

libsigsegv and responding to a stack overflow

自作多情 提交于 2019-12-04 07:17:00
We are attempting to test student code, and in an effort to automate the process, we'd like to detect if a student's code overflows the stack. I've met with some success using the libsigsegv library and its corresponding stackoverflow_install_handler. It works brilliantly, until the student's code blows the stack twice. For example, here's some sample output: [# ~]$ ledit ./interpreter -> (use solution) -> (fun 1 2) *** Stack overflow detected *** -> (fun 1 2) Signal -10 [# ~] The initial " * Stack overflow detected * " is the desirable output. After blowing the stack for the second time, all

Core dump while loading a file

倾然丶 夕夏残阳落幕 提交于 2019-12-04 06:59:17
问题 I am trying to create a function which loads data from a .txt file but when it runs I always get a segmentation fault(core dumped) error. The file contains an unknown number of lines while each line has a string and an integer separated by tab.The list_create function just creates a data structure. The while loop in the end deletes the data structure, I did not include the code because I am sure it does not cause the problem but I also want show that I am freeing the data structure.It is

Calc cell convertor in C

帅比萌擦擦* 提交于 2019-12-04 06:46:41
问题 I'm learning C and I have written a simple program (just a tanning). On input you pass two arguments (row and column) and output you get a Calc (or Excel) code for this cell. For example: Input: 3 1 Output: A3 Input: 1 27 Output: AA1 The code: #include <stdio.h> char kol[7] = ""; unsigned int passes=0, nr; int powa(unsigned int lv) { if(passes < nr) { if(kol[lv] == '\0') { kol[lv] = 'A'; kol[lv+1] = '\0'; } else { kol[lv]++; if(kol[lv] == 'Z'+1) { kol[lv] = 'A'; powa(lv+1); return 0; } }

Program received signal SIGSEGV, Segmentation fault. when debugging

对着背影说爱祢 提交于 2019-12-04 06:29:06
问题 If I debug my code then I get "Program received signal SIGSEGV, Segmentation fault." Here is my code- #include <stdio.h> #include <conio.h> #include <string.h> int main() { struct term { char* name; long int id; float term_gpa; }; struct term *term_ptr, student; term_ptr = &student; strcpy( term_ptr->name,"niton"); term_ptr->id = 942044; term_ptr->term_gpa = 3.75; printf("Name : %s",term_ptr->name); printf("Name : %s",student.name); getch(); return 0; } I get this error on line 17. Please

Why do programs sometimes “skip over” printfs?

試著忘記壹切 提交于 2019-12-04 06:08:38
问题 I have the following code: if (!strcmp(ent_child->d_name, "eeprom")){ printf("\tread_from_driver: found a match! ");//DEBUG get_child_path(child_path, child_path, "eeprom"); printf("The path is: %s\n", child_path);//DEBUG read_eeprom(child_path); } This causes a segfault at some point, (probably get_child_path), but the first printf never happens, even though when I fix the code to be this: if (!strcmp(ent_child->d_name, "eeprom")){ while(1) printf("\tread_from_driver: found a match! ");/

Why do I segfault?

时光毁灭记忆、已成空白 提交于 2019-12-04 05:50:27
问题 Here is my code, I'm getting a segmentation fault and I don't know why... I'm creating a grid which n is its size, tab is an array which his type is cellule : a cell has 2 values. So I'm creating in the function creer_grille an array I malloc it (size can be 4 6 or 8) and I initialize the cells values with -1 and 0. Then in the following function I'm testing the creer_grille function. typedef struct { int val; int initial; } cellule; typedef struct { cellule *tab; int n; } grille; grille

Identify variable causing memory error

ぃ、小莉子 提交于 2019-12-04 05:25:36
问题 So I have run into a weird error a few times now and im looking for some good directions as to identify the problem. Basically what I am seeing is a seg-fault. The symptoms are as follows: It occurs only when the program is in release mode, not in debug. It appears as a segfault and GDB tells me that it is in _list_release / _free() / free() at the end of a function. Program received signal SIGSEGV, Segmentation fault. 0xb0328af8 in _list_release () from /usr/qnx650/target/qnx6/x86/lib/libc

PHPUnit Segmentation Fault 11

风格不统一 提交于 2019-12-04 04:47:40
I tried running PHPUnit this morning and it's producing a Segmentation Fault 11 error (using the command phpunit unit/ - If I run PHPUnit on my functional tests with Selenium then everything works fine, it's only the unit tests that are affected, I've tried the options in other threads here and those didn't fix the issue, and I have tried reinstalling MAMP locally and reinstalling PHPUnit through PEAR. I've also tried switching PHP versions on the command-line. The tests run fine on a colleagues laptop, and they run fine within Jenkins. Does anyone have any ideas as to the issue? I've included

C++ Segmentation when using erase on std::list

青春壹個敷衍的年華 提交于 2019-12-04 04:07:43
I'm trying to remove items from a C++ linked list using erase and a list iterator: #include <iostream> #include <string> #include <list> class Item { public: Item() {} ~Item() {} }; typedef std::list<Item> list_item_t; int main(int argc, const char *argv[]) { // create a list and add items list_item_t newlist; for ( int i = 0 ; i < 10 ; ++i ) { Item temp; newlist.push_back(temp); std::cout << "added item #" << i << std::endl; } // delete some items int count = 0; list_item_t::iterator it; for ( it = newlist.begin(); count < 5 ; ++it ) { std::cout << "round #" << count << std::endl; newlist