[SOLVED] Seg Fault when running C program without root
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I had this problem before and though it was fixed with a new compiler.
Compile C program in my laptop, FC8,
gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure
Thread model: posix
gcc version 4.3.2 (GCC)
If you copied it to the server as "root," then the transferred files are owned by "root." The permissions of the files (and perhaps their location) might not permit anyone else to use them. This can apply both to the executable files or to any libraries.
Sometimes programs don't check whether an operation succeeded. They simply (say...) look-up the address of a routine they want to call, and attempt to call it using the address returned by the lookup function ... not checking if the address was NULL, as it would be if the routine could not be found. A subroutine-call to location $00000000 is a dead-certain superhighway to segfault-city.
If you copied it to the server as "root," then the transferred files are owned by "root." The permissions of the files (and perhaps their location) might not permit anyone else to use them. This can apply both to the executable files or to any libraries.
Sometimes programs don't check whether an operation succeeded. They simply (say...) look-up the address of a routine they want to call, and attempt to call it using the address returned by the lookup function ... not checking if the address was NULL, as it would be if the routine could not be found. A subroutine-call to location $00000000 is a dead-certain superhighway to segfault-city.
I found that I can execute the program with an ID that belongs to the group root. So I am beginning to think it has to do with permissions?
From ls:
ls -lrt vmshub
-rwxr-xr-x 1 root root 698927 Mar 30 12:34 vmshub
But I don't see the problem!
The first thing the program does is output a message, so I don't think it is a program error.
Well, I found the problem. Don't know why this caused the problem, but I was trying to limit the size of data files for this user and I put a rule in ulimit_conf to limit the data file size to 5K. Removing this limit and the program now runs.
Well, I found the problem. Don't know why this caused the problem, but I was trying to limit the size of data files for this user and I put a rule in ulimit_conf to limit the data file size to 5K. Removing this limit and the program now runs.
Can anyone explain what is going on??
Why should anyone explain you what's going on in your program ?
You have the source, so you can determine at what line the program segfaults.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.