Changeset 15572


Ignore:
Timestamp:
Jan 8, 2013, 5:33:39 PM (6 years ago)
Author:
gb
Message:

If we get a SIGSEGV or SIGBUS while executing foreign code when
tcr->safe_ref_address is non-nil, try to recover by making it look
like the current ffcall has returned a null pointer.

Try to use this mechanism to recognize tagged ObjC instances. (Part
of that process involves sending -[NSObject class] to something that
may or may not be an ObjC instance, and if the instance isn't valid
that message will likely generate a memory fault.)

Location:
trunk/source/lisp-kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/x86-exceptions.c

    r15500 r15572  
    17291729  stack_t ss;
    17301730
     1731  if ((tcr->valence != TCR_STATE_LISP) &&
     1732      (tcr->safe_ref_address) &&
     1733      ((signum == SIGBUS) || (signum == SIGSEGV))) {
     1734    extern opcode ffcall_return;
     1735    xpPC(context) = (natural)&ffcall_return;
     1736    xpGPR(context,Iimm0) = 0;
     1737    xpGPR(context,Isp) = (natural)(tcr->foreign_sp);
     1738    return;
     1739  }
     1740
     1741
     1742
     1743
     1744
    17311745#if WORD_SIZE==64
    17321746  if ((signum == SIGFPE) && (tcr->valence != TCR_STATE_LISP)) {
  • trunk/source/lisp-kernel/x86-spentry32.s

    r15500 r15572  
    42714271 * and the DF is clear.
    42724272 */
     4273        .globl C(ffcall_return)           
    42734274_spentry(ffcall)
    42744275LocalLabelPrefix`'ffcall:
     
    43084309LocalLabelPrefix`'ffcall_call:
    43094310        __(call *%eax)
     4311C(ffcall_return):               
    43104312        __ifdef(`WIN32_ES_HACK')
    43114313         __(movw tcr.ldt_selector(%ebx),%rcontext_reg)
  • trunk/source/lisp-kernel/x86-spentry64.s

    r15500 r15572  
    40734073/*   the function result will be in %rax (and possibly %rdx) or %xmm0 (+ %xmm1).  */
    40744074
     4075        .globl C(ffcall_return)
    40754076_spentry(ffcall)
    40764077LocalLabelPrefix`'ffcall:               
     
    41364137LocalLabelPrefix`'ffcall_call:
    41374138        __(call *%r11)
     4139C(ffcall_return):               
    41384140LocalLabelPrefix`'ffcall_call_end:               
    41394141        __ifdef(`WINDOWS')
Note: See TracChangeset for help on using the changeset viewer.