views:

586

answers:

1

I encountered "SYS#0" at the top of a stack and cannot find any documentation as to what that means.

  • Compiler: g++
  • OS: Solaris 9
  • Arch: SPARC
  • Memory Manager libhoard_32.so from Hoard 3.5.1

We used "gcore" to generate a core file. Looking at the output of running the "pstack" command against the core file, the only thread that was doing anything interesting had the following at the very top of its call stack:

ff309858 SYS#0    ()
ff309848 void MyHashMap<const void*,unsigned,AlignedMmapInstance<65536U>::SourceHeap>::set(const void*,unsigned) (ff31eed4, 9bf20000, 10000, 40, 9bf1fff0, ff31e738) + 134
...

pflags for that LWP shows:

/8:   flags = PR_STOPPED|PR_ISTOP|PR_ASLEEP
why = PR_REQUESTED
sigmask = 0xfffffeff,0x00003fff

I could not find any mention of this syntax in the Sun documentation.

Edit: The process appears to have hung sometime prior to doing the gcore. Is "SYS#0" somehow interrelated with process hangs?

Edit: Added next stack frame and link to Hoard, pflags output

Edit: The accepted answer is correct. In addition, at least on SPARC, the g1 register should contain the system call number, but this did not appear to be the case in our core file.

The topic "what is an indirect system call?" is probably good material for another question.

+2  A: 

Try this:

$ cat foo.c
#include <stdio.h>

int main(int argc, char *argv[]) {

    char buf[1024];
    proc_sysname(0, buf, 1024);
    printf("%s\n", buf);

}
$ gcc -ofoo -lproc foo.c
$ ./foo
SYS#0
$

SYS#0 is therefore the string that represents system call zero. If you look in <sys/syscall.h> (the system call table) you will find the following:

/* syscall enumeration MUST begin with 1 */

/*
 * SunOS/SPARC uses 0 for the indirect system call SYS_syscall
 * but this doesn't count because it is just another way
 * to specify the real system call number.
 */

#define SYS_syscall 0

The indirect system call syscall(SYS_syscall, foo, bar, ...) is equivalent to the direct call syscall(foo, bar, ...).

Martin Carpenter