Skip to content

Commit d9faa81

Browse files
JanWielemakerclaude
andcommitted
CLEANUP: rename O_C_STACK_GUARDED to O_ALTSIGSTACK
Nothing is guarded since the setjmp() context was removed; what the flag enables is handling SIGSEGV on an alternative signal stack. Also renames initGuardCStack() to initAltSignalStack(). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017dv8qG8JrSfiHguZaFbLAW
1 parent c4ef148 commit d9faa81

6 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/os/pl-cstack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ bstore_print_backtrace_named(btrace *bt, const char *why)
411411
void
412412
initBackTrace(void)
413413
{
414-
#if defined(SIGSEGV) && !defined(O_C_STACK_GUARDED)
414+
#if defined(SIGSEGV) && !defined(O_ALTSIGSTACK)
415415
PL_signal(SIGSEGV, sigCrashHandler);
416416
#endif
417417
#ifdef SIGILL

src/pl-global.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ struct PL_local_data
516516
#ifndef __unix__
517517
int forced; /* Forced signal */
518518
#endif
519-
#ifdef O_C_STACK_GUARDED
519+
#ifdef O_ALTSIGSTACK
520520
void *alt_stack; /* Stack to handle SIGSEGV on */
521521
#endif
522522
} signal;

src/pl-incl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,7 @@ typedef sigmask_t wsigmask_t[SIGMASK_WORDS];
23572357
Report C-stack overflows. An overflow raises SIGSEGV, but there is no C
23582358
stack left to run the handler on. On POSIX systems we therefore run
23592359
SIGSEGV on an alternative signal stack, so that sigCrashHandler() can
2360-
still print the crash report. See initGuardCStack().
2360+
still print the crash report. See initAltSignalStack().
23612361
23622362
Code that may need more C stack than is available asks for room using
23632363
require_c_stack(), which raises resource_error(c_stack).
@@ -2368,7 +2368,7 @@ this when compiling with the address sanitizer.
23682368

23692369
#if O_SIGNALS && defined(HAVE_SIGALTSTACK) && \
23702370
!defined(__SANITIZE_ADDRESS__)
2371-
#define O_C_STACK_GUARDED 1
2371+
#define O_ALTSIGSTACK 1
23722372
#endif
23732373

23742374

src/pl-setup.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -774,13 +774,13 @@ initTerminationSignals(void)
774774
#endif /*O_SIGNALS*/
775775

776776
/* Handle SIGSEGV on an alternative signal stack, so a C-stack overflow
777-
still gets us a crash report. See O_C_STACK_GUARDED.
777+
still gets us a crash report. See O_ALTSIGSTACK.
778778
*/
779779

780780
bool
781-
initGuardCStack(void)
781+
initAltSignalStack(void)
782782
{
783-
#ifdef O_C_STACK_GUARDED
783+
#ifdef O_ALTSIGSTACK
784784
GET_LD
785785
stack_t ss = {0};
786786

@@ -893,7 +893,7 @@ initSignals(DECL_LD)
893893
{ struct signame *sn = signames;
894894
#ifdef HAVE_OS_SIGNALS
895895
initTerminationSignals();
896-
initGuardCStack();
896+
initAltSignalStack();
897897
#endif /*HAVE_OS_SIGNALS*/
898898
initBackTrace();
899899
for( ; sn->name; sn++)
@@ -1782,7 +1782,7 @@ freePrologLocalData(PL_local_data_t *ld)
17821782
if ( ld->tabling.node_pool )
17831783
free_alloc_pool(ld->tabling.node_pool);
17841784

1785-
#ifdef O_C_STACK_GUARDED
1785+
#ifdef O_ALTSIGSTACK
17861786
if ( ld->signal.alt_stack )
17871787
free(ld->signal.alt_stack);
17881788
#endif

src/pl-setup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void resetSignals(void);
6969
void cleanupSignals(void);
7070
int handleSignals(void);
7171
void terminate_on_signal(int signo);
72-
bool initGuardCStack(void);
72+
bool initAltSignalStack(void);
7373

7474
bool initPrologStacks(size_t limit);
7575
void initPrologLocalData(void);

src/pl-thread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ initialise_thread(PL_thread_info_t *info)
656656
WITH_LD(info->thread_data) initPrologLocalData();
657657
info->thread_data->magic = LD_MAGIC;
658658

659-
initGuardCStack();
659+
initAltSignalStack();
660660

661661
return true;
662662
}

0 commit comments

Comments
 (0)