![]() |
Plz help me understand what this error means and gdb's bt result
Hi,
I'm getting segmentation fault randomly in my desktop app for fremantle and I just couldn't figure out what's causing it and the exact source code. I'm using gtk+, gdb and maemo-summoner in scratchbox. Following is the error message and the backtrace from gdb: Thanks Code:
Program received signal SIGSEGV, Segmentation fault. |
Re: Plz help me understand what this error means and gdb's bt result
Ok, maybe someone can pin-point why I'm getting segmentation fault on this code, rather than the ugly output above :):
Code:
#include <glib.h> |
Re: Plz help me understand what this error means and gdb's bt result
Code:
mode = (char *) malloc(sizeof(char*)); |
Re: Plz help me understand what this error means and gdb's bt result
Quote:
EDIT: I can't believe it, I thought it was needed :D but it was the source of problem damn me.... THANK YOU. |
Re: Plz help me understand what this error means and gdb's bt result
Quote:
|
Re: Plz help me understand what this error means and gdb's bt result
Ok guys, I'm confused again. I did without malloc() and worked fine in scratchbox(cmdline) and in the device(cmdline). So, thinking it will work, I implemented the same in my real app(Desktop App) but it failed, so I put all the print statements(:D I'm tooo lazy to use gdb unless its completely random) to see where exactly the seg fault is comming from then I found the line strcpy(mode, val) is the source coz the printf statement just before that gets executed and not the one immediately after ;). What do youse have to say about it? Thanks
BTW, I got over it using qwerty's suggestion but just curious to know why it didn't happen that other way.... |
Re: Plz help me understand what this error means and gdb's bt result
Quote:
If you're still in doubt, use Code:
printf("%d\n", sizeof(char *)); sizeof(char *) will return the size of a memory pointer, usually an unsigned int, 4 bytes. This is not what you want to allocate if you are to store something in the allocated memory. |
All times are GMT. The time now is 05:18. |
vBulletin® Version 3.8.8