Re: What is the purpose of %fs?
- From: Josef Moellers <josef.moellers@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 23 Dec 2005 09:17:27 +0100
John Reiser wrote:
Josef Moellers wrote:
While trying to analyse a problem with snmpd, I stumbled across instructions in the tls/libc that reference %fs. Where could I find information about the contents of that segment?
I've single-stepped through a small printf("Hello, world")-program but have found no instruction which populates this segment, yet it seems to exist and contains data.
It provides an addressing space for thread-local storage ("TLS").
I thought so.
See __NR_set_thread_area, __NR_get_thread_area in /usr/include/asm/unistd.h and the code for clone() in the glibc sources in glibc-2.3.5/sysdeps/unix/sysv/linux/i386/clone.S .
Thanks, I'll follow this.
Note that clone() takes 7 arguments as glibc routine, but only 5 as a system call. One of the arguments is the address to use for the base of %fs (or %gs, depending on machine.)
Strange thing is that snmpd (my target of investigation, see below) is single-threaded!
Note that glibc considers this to be none of your business.
When I'm need to find out what's happening, it _is_ my business.
In our setup, snmpd crashes during startup of our own sub-agents and we have set things up so it dumps core. One of the cores shows a stack trace where vfprintf calls strlen(0x7). Unfortunately, I cannot find this value 0x7 in vfprintf's parameters (as far as I can find them, which is pretty nasty in x86_64)!
So I tried to trace vfprintf's execution (using a perl script that interprets disassembled machine code) and it references %fs and later branches depending upon the values read from TLS.
We also use ElectricFence to see if it is somehow related to malloc/free in using a stale pointer. It does crash at a different location where it reads from an already freed location. That's our current state. It may be a race-condition during the concurrent initialization of several sub-agents, but we're far from anything definite.
Nonetheless: I'm a very curious person and it just bothers me not to know what's happening there. As we put it in German: Ich möchte nicht dumm sterben (I don't want to die stupid).
-- Josef Möllers (Pinguinpfleger bei FSC) If failure had no penalty success would not be a prize -- T. Pratchett
.
- Follow-Ups:
- Re: What is the purpose of %fs?
- From: Enrique Perez-Terron
- Re: What is the purpose of %fs?
- References:
- What is the purpose of %fs?
- From: Josef Moellers
- Re: What is the purpose of %fs?
- From: John Reiser
- What is the purpose of %fs?
- Prev by Date: Re: How come two process simulteneously getting spin lock...
- Next by Date: Re: What is the purpose of %fs?
- Previous by thread: Re: What is the purpose of %fs?
- Next by thread: Re: What is the purpose of %fs?
- Index(es):
Relevant Pages
|