SIGSEGV segmentation fault at strftime_l lib64/libc.so.6
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
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.
SIGSEGV segmentation fault at strftime_l lib64/libc.so.6
I'am porting pro*c codes from UNIX to LINUX. The codes are compiled and created executables successfully. But during run time its raising segmentation fault. I debugged the code step by step and the below is the output of GDB debug.
Breakpoint 4 at 0x3b19690f50 (gdb) n 525 strftime (buf, MAX_STRING_LEN, "%d/%b/%Y:%H:%M:%S", dummy_time); (gdb) n
Breakpoint 4, 0x0000003b19690f50 in strftime () from /lib64/libc.so.6 (gdb) n Single stepping until exit from function strftime, which has no line number information. 0x0000003b19690f70 in strftime_l () from /lib64/libc.so.6 (gdb) n Single stepping until exit from function strftime_l, which has no line number information.
Program received signal SIGSEGV, Segmentation fault. 0x0000003b19690f8b in strftime_l () from /lib64/libc.so.6
Actually in code the function strftime() is called not strftime_l(). But I have no idea why it is reaching strftime_l in /lib64/libc.so.6.
This issue is not coming in UNIX. please help on this.
I think it is pretty obvious, see man strftime. strftime has an implicite default locale, otherwise both do the same thing (so strftime calls strftime_l with an additional argument)
The segfault can be caused by either the buffer is too small or by an illegal variable handling (so for example dummy_time points to nowhere)
because strftime does nothing else just calls strftime_l passing all the original arguments and an additional one: the locale settings. The functionality is implemented in the function strftime_l.
could please help me where to see the definition or implementation of strftime() ? I tried to check whether it calls strftime_l() but I couldn't get where this function implementation is seen?
(this is obvious). It is usual in the linux world: you can have a few similar functions with almost the same functionality. some of them has default values or assumes some settings. In such cases all those functions invoke the most general one passing their inputs and adding the assumed ones. The functionality is implemented only once and in this general version.
Since this is part of libc you need to download the source code of it and look into the code for the real implementation (there will be a strftime.c or similar). you can find it for example here: http://www.gnu.org/software/libc/download.html
that is coming from your post. You told you wrote strftime, but you see strftime_l, and asked why. Either you called directly strftime_l or it is called from strftime. The "Single stepping until exit from function strftime" just walked into strftime_l and the code is died inside strftime_l.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.