LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   core dump on linux with err variable (https://www.linuxquestions.org/questions/programming-9/core-dump-on-linux-with-err-variable-642622/)

dayalan_cse 05-16-2008 06:42 AM

core dump on linux with err variable
 
hello,

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?

Is it related with variable name collision?

Please let me know.

Thank you in advance.

Thanks,
Deenadayalan

Nylex 05-16-2008 07:10 AM

I think we need to see some code.

dayalan_cse 05-25-2008 12:58 AM

core dump on linux with err variable
 
Quote:

Originally Posted by Nylex (Post 3155138)
I think we need to see some code.

Hi All,

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'

Thanks & Regards
Deenadayalan

Nylex 06-01-2008 12:30 AM

I haven't a clue about this, I'm afraid. Hopefully someone else will see your thread.

Hko 06-01-2008 05:49 AM

well, try to rename your global variable 'err' to see what happens then. If the problem persists, please post code.

dayalan_cse 06-03-2008 07:09 AM

core dump on linux with err variable
 
Quote:

Originally Posted by Hko (Post 3170991)
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.

Thanks,
Deenadayalan


All times are GMT -5. The time now is 02:19 PM.