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.
hi all
i have a question about network programming for u who can help me,
when i write some network program (usually using qt gui, socket), then i compiled and running as root, i got Segmentation Fault ( both su and sudo ), but running normal if using normal user, is thereis any one know the solution ?
Use the versions of the libraries etc with debug symbols intact, then compile your software and run it under 'gdb' and find out what causes the segfault.
thanks for replay
actually i never use gdb at all because i am win32 gui programming before ( i use ollydbg ).
I get same problem with precompiled one, the program is cafe billing (the client) that can lock client desktop on my Internet Cafe, if i execute the program using normal user then my user with little knowledge of unix can kill it either via shell or the others, any soluition
I don't see what solution you can have except to run it as 'root' and attach a debugger to find out where you get the segfault. It sounds suspiciously like a pointer is freed, then accessed again later. If no one else changes that memory and it isn't reclaimed by the kernel memory manager everything will be fine, but if it is altered for any reason then strange things can happen. The 'segfault' sounds like the memory was reclaimed by the kernel, so when the 'page' that it was on was accessed, a segfault was generated. Normally if you are accessing a page which was allocated to you, the page would be made available and the program goes on running (segfaults are normal program operation - as long as the kernel knows how to handle it), but since the kernel doesn't believe that address has been allocated to you, the process is killed with a segfault.
try the qt3 distribution network example, nothing wrong with the code, just doesnt work to run as root via su or sudo, acctually i am still lazy to grab debug library version in my computer, i am not really like to use gdb (cli debugger) too, another example is that i was try is zeiberbude (http://packages.debian.org/zeiberbude
the client one, it just tell me that "Segmentation Fault" was occur, i think this is about Environtment one, not the code, i not try yet but how if i am login as root through normal login not su or sudo, it could be work ??? I will try later
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.