How to overcome segmentation fault error?
Hi
Tens of my own created programs are aborted by kernel due to segmentation fault error I have searched but I have not found any acceptable solution! There are some suggestions about using gdb but I know that it will not solve the problem I have created my own debugger program but that also gets the segmentation fault error and stopped! I tried using insmode and modeprobe commands but they do not work too! Shall I create my own kernel? Or is there a way to control the current kernel and overcome this segfault error? Thank you in advance for any answer |
Quote:
Quote:
Quote:
|
Quote:
Quote:
|
99% of segmentation faults are caused by the programmer doing something silly with a pointer. Start by finding out exactly where the program crashes. If you can use gdb for that, so much the better. I could never get my head around that (too old, I reckon) so I would insert little messages and move them forward step by step through the program until the message failed to print before the crash. Then I knew where the crash was occurring. Messages to indicate the entry into and exit from functions are useful too. And in some cases, printing out the actual value of a pointer can help. I once had a program that crashed because a supposedly incrementing pointer wasn't incrementing.
|
Invariably, segmentation-faults are caused by one of two things:
A whole lot of this is unfortunately self-discpline, although object-oriented languages like C++ do make things considerably easier to keep track of. In any case – "it's not the kernel's fault." |
My answer
First:
Here I want to say thank you to the 3 high rank LQ members who have answered my post May be I am the problem! And maybe I have done some silly things! But currently I have created more than 600 programs and many of them do not work because of segfault I know that my programs are not compatible with libraries and or kernel! But my understanding is that Linux is a free software and so it must be changeable so I do not care about compatibility! Commands like insmde or modprobe failed because of this or something like that error: Module not supported As I searched segfault happens when a program trys to access parts of memory which is not allowed! I want my own programs to access all parts of OS if needed! This is how I intended them to work! So considering some terminal outputs like: Permission denied Or Segmentation fault Or S_create ... Aborted etc I think the kernel is involved because the only program which can stand/stop root seems to be kernel Anyhow I want my own programs to be the leader in OS and not an slave I am trying to change the system as I like and I think that I have the right to do so because of as I said OS is a free software So if possible help me to overcome kernel/system Thank you |
You seem to confuse "free software" with "error-free software", and "the right to change the kernel" with "guarantee that whatever I do, my programs will run".
Free software or not, if your programs are not compatible, they don't run. Use the tips you received. |
Illogical errors
Quote:
The code causing error is like this: If something then stop working/die/print-something ...etc So if you change the code the behaviour will change I am using c++ and g++ compiler During last 10 years I have reinstalled OS several times in cases I have succeeded and sometimes I was confronted with the emergency state! I even had disabled entering emergency state by changing the related code This time the system seems to become stronger! And I am tired of reinstalling the OS! Because every time I have to start from beginning and change a lot of settings! Now my commands do not work as I expect For example I coded as this: If segfault then ignore/continue/do-not-abort ...etc This is why I asked for help With or without help I will try to succeed and go ahead but I am not sure about the result! You know I am 71 years old now .. who knows about the future! Thank you for your attention but I can not return! |
Quote:
Quote:
Quote:
Quote:
|
I don't know why we discuss this at all. As well OP may try to walk upside-down. And complain that it doesn't work.
|
Yep. "It must be somebody else's fault." Maybe you can pay a lawyer to sue Linus Torvalds, since it's his kernel – maybe it's his fault. Or, the guy who comes twice a week to empty your waste bin – maybe it's his fault!
Or maybe you could sue the segment – obviously, it must be its fault: the computer just said so! |
istr reading somewhere that in early UNIX systems, segment violations were not policed effectively and systems often crashed because some badly-written program had overwritten a piece of the kernel. One of the superior things about Linux is the way the kernel polices the processes so that the system almost never crashes. Now this OP wants to return to the dark ages!
|
Not on my side!
I am not complaining about kernel behaviour! I want to make/force kernel to do what I want to be done! Because I am trying to develop all software in my computer even the current kernel!
One of my programs is named as: LAUHL which is an abreviation for: Learn And Use Human Languages I want to automatically upgrade software in my computer After that my intention is to share my knowledge with everyone But kernel/system do not or can not understand that , so they work as they are designed to work and any upgrade is designed to be done by parental site! Why?! Finally there would be no harm if my programs can access the memory related to other segments because generally my programs are designed to automatically upgrade computer Other software can not understand this and resist! My own made programs have always been restricted! They do not or can not remember their own work! In spite of my save/remember commands! My help request was because I assumed you are on my side! Are you?! |
Quote:
|
Perhaps a better place for this thread would be here:
https://www.linuxquestions.org/questions/programming-9/ |
All times are GMT -5. The time now is 09:35 PM. |