Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stack overflow handling for native code #6530

Closed
vicuna opened this issue Sep 1, 2014 · 2 comments
Closed

Add stack overflow handling for native code #6530

vicuna opened this issue Sep 1, 2014 · 2 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Sep 1, 2014

Original bug ID: 6530
Reporter: madroach
Assigned to: @damiendoligez
Status: closed (set by @damiendoligez on 2014-10-02T11:22:09Z)
Resolution: fixed
Priority: normal
Severity: tweak
Platform: amd64, i386
OS: OpenBSD
Version: 4.02.0+beta1 / +rc1
Target version: 4.02.1+dev
Fixed in version: 4.02.1+dev
Category: runtime system and C interface
Tags: patch
Monitored by: @gasche

Bug description

Below you find the #defines for OpenBSD i386 and amd64 stack overflow handling.

Additional information

/****************** AMD64, OpenBSD */

#elif defined(TARGET_amd64) && defined (SYS_openbsd)

#define DECLARE_SIGNAL_HANDLER(name)
static void name(int sig, siginfo_t * info, struct sigcontext * context)

#define SET_SIGACT(sigact,name)
sigact.sa_sigaction = (void (*)(int,siginfo_t *,void *)) (name);
sigact.sa_flags = SA_SIGINFO

#define CONTEXT_PC (context->sc_rip)
#define CONTEXT_EXCEPTION_POINTER (context->sc_r14)
#define CONTEXT_YOUNG_PTR (context->sc_r15)
#define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)

/****************** I386, BSD_ELF */

#elif defined(TARGET_i386) && defined(SYS_bsd_elf)

#define DECLARE_SIGNAL_HANDLER(name)
static void name(int sig, siginfo_t * info, struct sigcontext * context)

#define SET_SIGACT(sigact,name)
sigact.sa_sigaction = (void (*)(int,siginfo_t *,void *)) (name);
sigact.sa_flags = SA_SIGINFO

#define CONTEXT_PC (context->sc_eip)
#define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)

The configure script needs to be amended, too:

@@ -1324,7 +1326,8 @@ fi

Determine if system stack overflows can be detected

case "$arch,$system" in

  • i386,linux_elf|amd64,linux|power,rhapsody|amd64,macosx|i386,macosx)
  • i386,linux_elf|amd64,linux|power,rhapsody|amd64,macosx|i386,macosx| \
  • amd64,openbsd|i386,bsd_elf)
    inf "System stack overflow can be detected."
    echo "#define HAS_STACK_OVERFLOW_DETECTION" >> s.h;;
    *)
@vicuna
Copy link
Author

vicuna commented Sep 1, 2014

Comment author: madroach

here the patch against signals_osdep.h:

--- asmrun/signals_osdep.h.orig Tue May 13 15:20:48 2014
+++ asmrun/signals_osdep.h Sun Aug 31 20:22:33 2014
@@ -130,6 +130,22 @@
#define CONTEXT_YOUNG_PTR (context->uc_mcontext.gregs[REG_R15])
#define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)

+/****************** AMD64, OpenBSD */
+
+#elif defined(TARGET_amd64) && defined (SYS_openbsd)
+

  • #define DECLARE_SIGNAL_HANDLER(name) \
  • static void name(int sig, siginfo_t * info, struct sigcontext * context)
  • #define SET_SIGACT(sigact,name) \
  • sigact.sa_sigaction = (void (*)(int,siginfo_t *,void *)) (name); \
  • sigact.sa_flags = SA_SIGINFO
  • #define CONTEXT_PC (context->sc_rip)
  • #define CONTEXT_EXCEPTION_POINTER (context->sc_r14)
  • #define CONTEXT_YOUNG_PTR (context->sc_r15)
  • #define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)

/****************** I386, Linux */

#elif defined(TARGET_i386) && defined(SYS_linux_elf)
@@ -142,6 +158,20 @@
sigact.sa_flags = 0

#define CONTEXT_FAULTING_ADDRESS ((char ) context.cr2)
+
+/
***************** I386, BSD_ELF */
+
+#elif defined(TARGET_i386) && defined(SYS_bsd_elf)
+

  • #define DECLARE_SIGNAL_HANDLER(name) \
  • static void name(int sig, siginfo_t * info, struct sigcontext * context)
  • #define SET_SIGACT(sigact,name) \
  • sigact.sa_sigaction = (void (*)(int,siginfo_t *,void *)) (name); \
  • sigact.sa_flags = SA_SIGINFO
  • #define CONTEXT_PC (context->sc_eip)
  • #define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)

/****************** I386, BSD */

@vicuna
Copy link
Author

vicuna commented Sep 28, 2014

Comment author: @damiendoligez

I've applied the patches (rev 15363). I'll close the PR if the CI reports no problems (it tests with OpenBSD i386).

@vicuna vicuna closed this as completed Oct 2, 2014
@vicuna vicuna added the stdlib label Mar 14, 2019
@vicuna vicuna added this to the 4.02.1 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants