2
votes
Accepted
PSET5 Speller / Dictionary - Seg Fault and Incorrect Check
You can jump to SUGGESTION for quick answer.
I plugged your check() function on my dictionary.c program. I also have a trie in my dictionary.c.
I don't know what is causing the segmentation fault. ...
2
votes
Cant create linked list node
This is a really tricky mistake happened around line 50-53. A live test of your code is available here: segfault fixed, I made a fix at line 52-53 and commented out the faulty code. It works ...
2
votes
Do YOU know how to find a seg fault?? Advice to new programmers
Reread the post again, he explains why the seg fault happens. A quick google should suffice too.
2
votes
Crack: Segfault on CS50 appliance/ IDE/ CS50.io but fine on my computer
Ok, I've found answer to c segmentation fault on tail recursion:
changing clang option -o from 0 to 3 fixes this problem as this enables better optimization:
clang -fsanitize=integer -fsanitize=...
2
votes
Crack: Segfault on CS50 appliance/ IDE/ CS50.io but fine on my computer
if(!offset) offset = 0; does nothing. 0 is the value of false, while anything different could be interpreted as true in many contexts (even if it does not equal true, which is 1).
With word[offset=='...
1
vote
Accepted
PSET6 Load - Check50 Server2 Errors
The program reads one byte at a time and essentially appends it to buffer. So the number of bytes that buffer needs to hold increases each read. This buffer = realloc(buffer, sizeof(char)); allocates ...
1
vote
Do YOU know how to find a seg fault?? Advice to new programmers
A better way to identify the source of segmentation faults is to compile with
-g -fsanitize=undefined -fsanitize=address
running the program should then point you to the exact line where the ...
1
vote
Pset 5 Speller Segmentation Fault
Your code is very nice and neat congratulations. Your problem resides in your hash function. When passed a string of less than 3 caracters returns a negative value, so when you try to use it as index ...
1
vote
Accepted
Pset5 Trie Segmentation fault
It could be because you're looking in the wrong place. The code is seg faulting in the unload() function. Specifically, it fails at this line:
child[i] = curr->children[i];
The seg fault ...
1
vote
Accepted
speller seg fault
It's a common problem. ;-)
Look carefully at the unload() code. In particular, this line:
while(cursor -> next != NULL)
Now, what happens if cursor itself is null? cursor->next doesn't ...
1
vote
Accepted
Getting a segmentation fault on cs50's speller (pset5)
For starters, the program doesn't actually compile without error. It's probably compiling in your environment with a warning about an unused parameter in the call to load().
In most people's ...
1
vote
Accepted
Pset5 - Speller - Seg fault
There is a serious logic problem here. The load code only allocates one node, before the start of the while loop. All words are going to be added to that one node. (I leave it to you to study exactly ...
1
vote
Accepted
The third last line of code is the one causing a segmentation fault. When removed, nothing happens and all I get is a $ on a new line in the terminal
The while executes an fread followed immediately by an fread. What is likely happening is: program never finds a jpeg signature because it is only processing every other block. Therefore, no img file ...
1
vote
Accepted
Word array sometimes filled with weird values - Speller
The random values you see in word is the result of previous iterations of the loop assigning longer words than the current one. It's not an issue per se since the functions handling it (such as strlen ...
1
vote
Accepted
Trying to fix a segfault in unload , pset5, speller
For starters, you can't free table[i] and two lines later try to access table[i]->next. It no longer exists. That's where the seg fault comes from.
This unload code is needlessly complicated. I ...
1
vote
Accepted
PSET 5 Unload Segmentation Fault
Two problems. First, table[] was never initialized. Second, the if statement in unload allows i to be 27, which means that table[27] is selected, but doesn't exist.
There may be other issues, but ...
1
vote
Pset5 Seg fault speller
There was a little bit of code missing, so I can't tell exactly why you're getting the seg fault for sure, but I'm 99% certain of the problem.
The code is treating word_count as a pointer. Why? ...
1
vote
CS50 PSET4 RECOVER.C SEGMENTATION FAULT PLEASE HELP!
Having a look at your code was really helpful, I was having a hard time with this problem because I cant fully understand how fread works.
You keep reading rawPtr and sending it to buffer, and the ...
1
vote
Cant create linked list node
The first thing I noticed is that the hashtable array is not allocated here hashtable[i] = NULL;. Remember, each index can hold a node. I fixed that in my repro case, but the error persisted.
I ...
1
vote
Segfault error in initials program
while(isspace(name[length - i]) && w == true) {
++i;
}
This loop is the culprit. when i increases, and length - i decreases. At some iterations length-i will become a negative value, and ...
1
vote
Accepted
Pset5: load hashtable - constantly giving seg fault
You forget to fclose the dictionary, but else...
l_node->next = NULL; would be a bad idea before testing if l_node == NULL.
Make sure your buffer variable and word property both can handle a word ...
1
vote
Accepted
No errors while loading small dict, but segfault when loading large one. Pset5 Speller
Apostrophe problem. Apostrophe is 39 in ascii. (96 is backwards apostrophe, or back-tick).
When check encounters apostrophe here if (word[c]<91) translated=word[c]-65; translated is a negative ...
1
vote
Pset4, Recover, GDB on fread gives an "Coud not open file" error and segfault
The problem was fileName array, it needs to be 8, not 7. sprintf was overwriting important memory because of that.
1
vote
pset5 Segmentation fault
You were on the right track. buckets is declared as an array of pointers, but they're not initialized, so they contain garbage data. They do need to be initialized. Next, the compiler is choking ...
1
vote
Accepted
pset6 server giving segfault
Remember that you can't change the length of a string array once it has been created in c. Now look at the following:
char requestTarget[] = "";
char query[] = "";
This code creates a couple ...
1
vote
pset5 speller.c with hashtable errors and seg fault
use tools like gdb and valgrind to detect the cause of the problem and solve it!
your load function:
also do you think relying on feof may cause you to allocate more memory than you need?
are you ...
1
vote
Accepted
Vigenere code has Segmentation error
Your segmentation fault is due to the following line:
if(isalpha(argv[1]))//checks if key is letters
isalpha() tests to see if a single character is an alpha. It does not operate on whole strings. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
segfault × 51pset5 × 21
segmentation-fault × 17
speller × 15
recover × 8
pset4 × 7
load × 6
unload × 6
pset6 × 4
c × 4
trie × 4
check50 × 2
error × 2
check × 2
dictionary × 2
string × 2
recursion × 2
debug50 × 2
pset2 × 1
cs50x × 1
vigenere × 1
appliance × 1
server × 1
valgrind × 1
breakout × 1