Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why SIGILL ???

21 views
Skip to first unread message

umesh.k...@gmail.com

unread,
Sep 27, 2012, 5:58:14 AM9/27/12
to
Pardon me to interpret you guys with my question.

About SIGILL signal,
According to wiki.

On POSIX-compliant platforms, SIGILL is the signal sent to a process when it attempts to execute a malformed, unknown, or privileged instruction. The symbolic constant for SIGILL is defined in the signal.h header file. Symbolic signal names are used because signal numbers can vary across platforms.

SA_SIGINFO macros
ILL_ILLOPC illegal opcode
ILL_ILLOPN illegal operand
ILL_ILLADR illegal addressing mode
ILL_ILLTRP illegal trap
ILL_PRVOPC privileged opcode
ILL_PRVREG privileged register
ILL_COPROC coprocessor error
ILL_BADSTK internal stack error


Take below sample

#include <dirent.h>
#include <stdio.h>

int main (void)
{
DIR* dir = opendir("/usr/lib");
if (dir)
{
struct dirent* d = NULL;
while ((d = readdir(dir)) != NULL)
{
const char* local = d->d_name; // bam!
printf ("%s\n", local);
}
closedir(dir);
}

return 0;
}



When we try to compile and run the code on X OS i.e

$ ./a.out
.
..
arc
Illegal instruction: 4

After debugging the sample,it turns out be unaligned pointer access,

The question here is that OS should had been signaled with SIGBUS then SIGILL,Because according wiki the SIGILL signaled when there is “malformed, unknown, or privileged instruction.”

Did I’m missing something here ????

Thanks
~Umesh

0 new messages