LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-29-2009, 03:40 PM   #1
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Rep: Reputation: 40
Seg Fault when running C program without root


Hi group,

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)
  • runs fine on laptop.
  • scp to my server, FC5
  • runs fine under root
  • Seg Faults for non-root ID
I used -static in the link.

Any ideas??
 
Old 03-29-2009, 10:08 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,657
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
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.
 
Old 03-30-2009, 02:49 PM   #3
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
Update

Quote:
Originally Posted by sundialsvcs View Post
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.
 
Old 03-30-2009, 03:04 PM   #4
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
Fixed!

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??
 
Old 03-30-2009, 03:46 PM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by MrUmunhum View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
strcat is causing seg fault (c program) mfrick Programming 9 08-20-2014 07:34 AM
seg fault / mem fault - in cron, but works in shell? kauaikat Linux - Software 1 04-29-2008 08:21 AM
"C" program creates Seg fault 320mb Programming 4 06-24-2006 02:31 PM
Seg fault with root on ramdisk nawazsa Programming 0 12-08-2003 01:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration