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 declared variable called err as int variable. there is function called fun_calculate which returns the status to err variable, when the return type value has being written in err variable it core dumps.
Can any one help me to understand why this core dump if i write value in to err variable?
the core dump is because of my code has global variable called err and the other hand err is function defined in err.h in gcc, it seems that when linker links all the .o files it picks up err definition from the libc.so.6 file instead of from my code (definition err variable) so it causes the core dump when there is write in err global variable (err=2).
here is the log from LD_DEBUG.
main_ml.so to /lib/tls/libc.so.6: normal symbol `err'
well, try to rename your global variable 'err' to see what happens then. If the problem persists, please post code.
Hi,
If i change my variable name from err to some other name for example myerr then it is not crashing because there is no clash between user code (executable) and with libc.so.6.
the crash is mainly because of err variabel if i change the variable name then there is no core dump.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.