java: fix NPE when context is called from a thread attached via JNI

In such case current context was not initialized. The fix is to default to master context.

Reported-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
memory: switch leak detector to backtrace_safe()

The scenario

  run elf image
    demand page fault
      allocation
        leak detector tracking
           backtrace()
             access dwarf tables

leads to a nested demand page fault, which we don't (and probably can't)
support.  Switch to backtrace_safe(), which is of lower quality, but is safer.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64: nested exceptions

The scenario

  run elf file
    demand fault
      allocation
        leak detector tracking
          backtrace_safe()
            page fault

leads to a nested exception.  Add support for it by allocating an extra
stack.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>