Candidate Screening Challenges (Was: Crazy idea from a recruiter)

Sasha Pachev sasha at asksasha.com
Fri Mar 29 15:44:13 MDT 2013


> Does installing a signal handler disqualify?

Dennis gets the prize! And of course the same thing can be done to
deal with SIGSEGV. Isn't this fun? Now if you want to enter an
obfuscated code contest, here is an idea:

 - install the signal handler in an obscure way somewhere far far away
from where it will be invoked
- invoke you code by intentionally segfaulting or dividing by zero in
a subtle way that is easy to miss on visual inspection, maybe
something like this:

uint16 n, k = 2;
n = (1 << 15);
n *= k;
b = a/n;

Ok, next challenge. Is it possible for the following to segfault on Linux:

uint mem_size;
char* p, *p_end;

mem_size = get_mem_size(); // this works as expected, no segfault here

if (!(p = (char*)malloc(mem_size)))
{
  fprintf(stderr,"Out of memory\n");
  exit(1);
}

for (p_end = p + mem_size; p < p_end; )
{
   *p++ = 0xff;
}

?

-- 
Sasha Pachev

Fast Running Blog.
http://fastrunningblog.com
Run. Blog. Improve. Repeat.


More information about the PLUG mailing list