Skip to content

Commit

Permalink
Temporary / for CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
xclerc committed Apr 24, 2024
1 parent a16c8a3 commit a9c6223
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
17 changes: 17 additions & 0 deletions ocaml/runtime/amd64.S
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,23 @@ LBL(caml_call_gc):
CFI_ENDPROC
ENDFUNCTION(G(caml_call_gc))

FUNCTION(G(caml_raise_stack_overflow_XXX))
CFI_STARTPROC
CFI_SIGNAL_FRAME
ENTER_FUNCTION
LBL(caml_raise_stack_overflow_XXX):
SAVE_ALL_REGS
movq %r15, Caml_state(gc_regs)
SWITCH_OCAML_TO_C
C_call (GCALL(caml_raise_stack_overflow))
SWITCH_C_TO_OCAML
movq Caml_state(gc_regs), %r15
RESTORE_ALL_REGS
LEAVE_FUNCTION
ret
CFI_ENDPROC
ENDFUNCTION(G(caml_raise_stack_overflow_XXX))

FUNCTION(G(caml_alloc1))
CFI_STARTPROC
ENTER_FUNCTION
Expand Down
9 changes: 7 additions & 2 deletions ocaml/runtime/signals_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

#define CAML_INTERNALS

#include <unistd.h>
#define __USE_GNU
#include <sys/ucontext.h>

/* Signal handling, code specific to the native-code compiler */

#include <signal.h>
Expand Down Expand Up @@ -93,7 +97,8 @@ void caml_garbage_collection(void)
sigact.sa_sigaction = (void (*)(int,siginfo_t *,void *)) (name); \
sigact.sa_flags = SA_SIGINFO

#include <unistd.h>

CAMLextern void caml_raise_stack_overflow_XXX(void);

DECLARE_SIGNAL_HANDLER(segv_handler)
{
Expand All @@ -104,7 +109,7 @@ DECLARE_SIGNAL_HANDLER(segv_handler)
char* protected_low = (char *) block + page_size;
char* protected_high = protected_low + page_size;
if ((fault_addr >= protected_low) && (fault_addr < protected_high)) {
caml_raise_stack_overflow();
context->uc_mcontext.gregs[REG_RIP]= (greg_t) &caml_raise_stack_overflow_XXX;
} else {
act.sa_handler = SIG_DFL;
act.sa_flags = 0;
Expand Down
1 change: 0 additions & 1 deletion ocaml/testsuite/tests/runtime-errors/stackoverflow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*)
let rec f x =
if not (x = 0 || x = 10000 || x = 20000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ x = 20000
x = 10000
x = 0
second Stack overflow caught
Called from Stackoverflow in file "stackoverflow.ml", line 35, characters 4-47
Called from Stackoverflow in file "stackoverflow.ml", line 34, characters 4-47
!p = 42

0 comments on commit a9c6223

Please sign in to comment.