void push(int i) { if (is_full()) { stack_overflow(); } else { contents[top++] = i; } }
void push(char i) { if (is_full()) stack_overflow(); else contents[top++] = i; }
void push(int digit) { if(is_full()) stack_overflow(); else stack[top++] = digit; }
void push(char c) { if(is_full()) { stack_overflow(); } else { contents[top++] = c; } }
int main(){ #ifdef test2 int bofsd[10000000]; bofsd[na]=nb; return bofsd[1000]; #endif #ifdef test3 stack_overflow(); #endif #ifdef test4 int* x = NULL; printf("Look what I found!!! %d", *x); #endif #ifdef test5 //silly expression involving globals to defeat optimiser printf("Look at this!! %d", nb / (nb - 2 * na)); #endif #ifdef test6 for (;;)nop(); #endif #ifdef test7 int x; scanf("%d", x); #endif #ifdef test8 fork(); #endif return 42; }
void main() { /* array(); dynamic_array(); dynamic_malloc_all();*/ printf("%d\n",sizeof(int)); stack_overflow(INT_MAX,INT_MAX); }
void push(int c){ if (is_full()){ stack_overflow(); exit (EXIT_SUCCESS); }else{ contents[top++] = c; } }
static void stack_underflow( young_heap_t *heap ) { word *globals = DATA(heap)->globals; globals[ G_STKUFLOW] += 1; if (!stk_restore_frame( globals )) stack_overflow( heap ); /* [sic] */ }
void push(int item) { if (is_full()) { stack_overflow(); } else { contents[top] = item; top += 1; } }
void push(int item) { if (is_full()) stack_overflow(); else { *top++ = item; } }
static void creg_set( young_heap_t *heap, word k ) { word *globals = DATA(heap)->globals; stk_clear( globals ); globals[ G_CONT ] = k; if (!stk_restore_frame( globals )) stack_overflow( heap ); /* [sic] */ }
static void fptan(void) { FPU_REG *st_new_ptr; int q; char arg_sign = FPU_st0_ptr->sign; if (STACK_OVERFLOW) { stack_overflow(); return; } switch (FPU_st0_tag) { case TW_Valid: #ifdef DENORM_OPERAND if ((FPU_st0_ptr->exp <= EXP_UNDER) && (denormal_operand())) return; #endif /* DENORM_OPERAND */ FPU_st0_ptr->sign = SIGN_POS; if ((q = trig_arg(FPU_st0_ptr)) != -1) { if (q & 1) reg_sub(&CONST_1, FPU_st0_ptr, FPU_st0_ptr, FULL_PRECISION); poly_tan(FPU_st0_ptr, FPU_st0_ptr); FPU_st0_ptr->sign = (q & 1) ^ arg_sign; if (FPU_st0_ptr->exp <= EXP_UNDER) arith_underflow(FPU_st0_ptr); push(); reg_move(&CONST_1, FPU_st0_ptr); setcc(0); } else { /* Operand is out of range */ setcc(SW_C2); FPU_st0_ptr->sign = arg_sign; /* restore st(0) */ return; } break; case TW_Infinity: /* Operand is out of range */ setcc(SW_C2); FPU_st0_ptr->sign = arg_sign; /* restore st(0) */ return; case TW_Zero: push(); reg_move(&CONST_1, FPU_st0_ptr); setcc(0); break; default: single_arg_error(); break; } }
static void fld_const(FPU_REG * c) { FPU_REG *st_new_ptr; if (STACK_OVERFLOW) { stack_overflow(); return; } push(); reg_move(c, FPU_st0_ptr); status_word &= ~SW_C1; }
static void handle_2_opcode(opcode instr, chip_8_cpu cpu) { if (cpu->stack_pointer == STACK_SIZE) { stack_overflow(cpu); } cpu->performed_jump = true; // jump back to the instruction AFTER the CALL opcode cpu->stack[cpu->stack_pointer] = cpu->program_counter + 1; cpu->stack_pointer = cpu->stack_pointer + 1; address new_program_counter = get_last_three_nibbles(instr); cpu->program_counter = new_program_counter; }
void fld_i_() { FPU_REG *st_new_ptr; if (STACK_OVERFLOW) { stack_overflow(); return; } /* fld st(i) */ if (NOT_EMPTY(FPU_rm)) { reg_move(&st(FPU_rm), st_new_ptr); push(); } else { if (control_word & EX_Invalid) { /* The masked response */ push(); stack_underflow(); } else EXCEPTION(EX_StackUnder); } }
static void fxtract(void) { FPU_REG *st_new_ptr; register FPU_REG *st1_ptr = FPU_st0_ptr; /* anticipate */ if (STACK_OVERFLOW) { stack_overflow(); return; } if (!(FPU_st0_tag ^ TW_Valid)) { long e; #ifdef DENORM_OPERAND if ((FPU_st0_ptr->exp <= EXP_UNDER) && (denormal_operand())) return; #endif /* DENORM_OPERAND */ push(); reg_move(st1_ptr, FPU_st0_ptr); FPU_st0_ptr->exp = EXP_BIAS; e = st1_ptr->exp - EXP_BIAS; convert_l2reg(&e, st1_ptr); return; } else if (FPU_st0_tag == TW_Zero) { char sign = FPU_st0_ptr->sign; divide_by_zero(SIGN_NEG, FPU_st0_ptr); push(); reg_move(&CONST_Z, FPU_st0_ptr); FPU_st0_ptr->sign = sign; return; } else if (FPU_st0_tag == TW_Infinity) { char sign = FPU_st0_ptr->sign; FPU_st0_ptr->sign = SIGN_POS; push(); reg_move(&CONST_INF, FPU_st0_ptr); FPU_st0_ptr->sign = sign; return; } else if (FPU_st0_tag == TW_NaN) { if (!(FPU_st0_ptr->sigh & 0x40000000)) { /* Signaling ? */ EXCEPTION(EX_Invalid); /* Convert to a QNaN */ FPU_st0_ptr->sigh |= 0x40000000; } push(); reg_move(st1_ptr, FPU_st0_ptr); return; } else if (FPU_st0_tag == TW_Empty) { /* Is this the correct * behaviour? */ if (control_word & EX_Invalid) { stack_underflow(); push(); stack_underflow(); } else EXCEPTION(EX_StackUnder); } #ifdef PARANOID else EXCEPTION(EX_INTERNAL | 0x119); #endif /* PARANOID */ }
void load_store_instr(char type) { FPU_REG *pop_ptr; /* We need a version of FPU_st0_ptr which won't change. */ pop_ptr = NULL; /* Initialized just to stop compiler warnings. */ switch ( type_table[(int) (unsigned) type] ) { case _NONE_: break; case _REG0_: pop_ptr = &st(0); /* Some of these instructions pop after storing */ FPU_st0_ptr = pop_ptr; /* Set the global variables. */ FPU_st0_tag = FPU_st0_ptr->tag; break; case _PUSH_: { pop_ptr = &st(-1); if ( pop_ptr->tag != TW_Empty ) { stack_overflow(); return; } top--; } break; case _null_: return Un_impl(); #ifdef PARANOID default: return EXCEPTION(EX_INTERNAL); #endif PARANOID } switch ( type ) { case 000: /* fld m32real */ reg_load_single(); reg_move(&FPU_loaded_data, pop_ptr); break; case 001: /* fild m32int */ reg_load_int32(); reg_move(&FPU_loaded_data, pop_ptr); break; case 002: /* fld m64real */ reg_load_double(); reg_move(&FPU_loaded_data, pop_ptr); break; case 003: /* fild m16int */ reg_load_int16(); reg_move(&FPU_loaded_data, pop_ptr); break; case 010: /* fst m32real */ reg_store_single(); break; case 011: /* fist m32int */ reg_store_int32(); break; case 012: /* fst m64real */ reg_store_double(); break; case 013: /* fist m16int */ reg_store_int16(); break; case 014: /* fstp m32real */ if ( reg_store_single() ) pop_0(); /* pop only if the number was actually stored (see the 80486 manual p16-28) */ break; case 015: /* fistp m32int */ if ( reg_store_int32() ) pop_0(); /* pop only if the number was actually stored (see the 80486 manual p16-28) */ break; case 016: /* fstp m64real */ if ( reg_store_double() ) pop_0(); /* pop only if the number was actually stored (see the 80486 manual p16-28) */ break; case 017: /* fistp m16int */ if ( reg_store_int16() ) pop_0(); /* pop only if the number was actually stored (see the 80486 manual p16-28) */ break; case 020: /* fldenv m14/28byte */ fldenv(); break; case 022: /* frstor m94/108byte */ frstor(); break; case 023: /* fbld m80dec */ reg_load_bcd(); reg_move(&FPU_loaded_data, pop_ptr); break; case 024: /* fldcw */ RE_ENTRANT_CHECK_OFF control_word = get_fs_word((unsigned short *) FPU_data_address); RE_ENTRANT_CHECK_ON #ifdef NO_UNDERFLOW_TRAP if ( !(control_word & EX_Underflow) ) { control_word |= EX_Underflow; } #endif FPU_data_address = (void *)data_operand_offset; /* We want no net effect */ FPU_entry_eip = ip_offset; /* We want no net effect */ break; case 025: /* fld m80real */ reg_load_extended(); reg_move(&FPU_loaded_data, pop_ptr); break; case 027: /* fild m64int */ reg_load_int64(); reg_move(&FPU_loaded_data, pop_ptr); break; case 030: /* fstenv m14/28byte */ fstenv(); FPU_data_address = (void *)data_operand_offset; /* We want no net effect */ FPU_entry_eip = ip_offset; /* We want no net effect */ break; case 032: /* fsave */ fsave(); FPU_data_address = (void *)data_operand_offset; /* We want no net effect */ FPU_entry_eip = ip_offset; /* We want no net effect */ break; case 033: /* fbstp m80dec */ if ( reg_store_bcd() ) pop_0(); /* pop only if the number was actually stored (see the 80486 manual p16-28) */ break; case 034: /* fstcw m16int */ RE_ENTRANT_CHECK_OFF verify_area(VERIFY_WRITE,FPU_data_address,2); put_fs_word(control_word, (short *) FPU_data_address); RE_ENTRANT_CHECK_ON FPU_data_address = (void *)data_operand_offset; /* We want no net effect */ FPU_entry_eip = ip_offset; /* We want no net effect */ break; case 035: /* fstp m80real */ if ( reg_store_extended() ) pop_0(); /* pop only if the number was actually stored (see the 80486 manual p16-28) */ break; case 036: /* fstsw m2byte */ status_word &= ~SW_TOP; status_word |= (top&7) << SW_TOPS; RE_ENTRANT_CHECK_OFF verify_area(VERIFY_WRITE,FPU_data_address,2); put_fs_word(status_word,(short *) FPU_data_address); RE_ENTRANT_CHECK_ON FPU_data_address = (void *)data_operand_offset; /* We want no net effect */ FPU_entry_eip = ip_offset; /* We want no net effect */ break; case 037: /* fistp m64int */ if ( reg_store_int64() ) pop_0(); /* pop only if the number was actually stored (see the 80486 manual p16-28) */ break; } }
int run() { printf("%s: Attempting to cause a stack overflow...\n", get_instance_name()); stack_overflow(); return 0; }
void stack_overflow(){ stack_overflow(); nop(); }
void stack_overflow() { int foo[1000]; (void)foo; stack_overflow(); }
static void stack_overflow(void) { char x[1024] UNUSED; asm volatile(""); stack_overflow(); asm volatile(""); }