Skip to content

Commit

Permalink
WIP: Use sigaction to fix multiple test failures under ASan
Browse files Browse the repository at this point in the history
This commit fixes multiple test failures when the coprocess, io and pty
tests are run under ASan. Unlike the ksh93v- approach of implementing
sigaction via a sh_signal function, this commit repurposes the
(otherwise unused) signal wrapper function in libast, which already uses
sigaction for signal handling.

src/lib/libast/features/map.c:
- Use the libast signal function if sigaction is present.
- Add necessary sig.h include (the Mamfile was also updated to account
  for this).
  • Loading branch information
JohnoKing committed Jan 22, 2024
1 parent 00b296c commit ad055bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/lib/libast/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ make install
done FEATURE/options generated
prev FEATURE/mmap
prev FEATURE/lib
make sig.h implicit
make FEATURE/sig
prev features/sig.sh
exec - iffe ${IFFEFLAGS} -v -X ast -X std -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" run features/sig.sh
done FEATURE/sig generated
exec - ${STDCP} -f FEATURE/sig sig.h
done sig.h generated
done features/map.c
exec - iffe ${IFFEFLAGS} -v -X ast -X std -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. ${LDFLAGS}" run features/map.c
done FEATURE/map generated
Expand Down Expand Up @@ -1109,13 +1116,7 @@ make install
make signal.o
make misc/signal.c
prev ast_map.h
make sig.h implicit
make FEATURE/sig
prev features/sig.sh
exec - iffe ${IFFEFLAGS} -v -X ast -X std -c "${CC} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS}" run features/sig.sh
done FEATURE/sig generated
exec - ${STDCP} -f FEATURE/sig sig.h
done sig.h generated
prev sig.h
prev include/ast.h
done misc/signal.c
exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Icomp -Iinclude -Istd -c misc/signal.c
Expand Down
10 changes: 7 additions & 3 deletions src/lib/libast/features/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2023 Contributors to ksh 93u+m *
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 2.0 *
* *
Expand Down Expand Up @@ -31,6 +31,7 @@
#include "FEATURE/vmalloc"
#include "FEATURE/eaccess"
#include "FEATURE/api"
#include <sig.h>

#if _opt_map_libc && !defined(_map_libc)
#define _map_libc 1
Expand Down Expand Up @@ -134,6 +135,11 @@ main(void)
printf("#define glob _ast_glob\n");
printf("#undef globfree\n");
printf("#define globfree _ast_globfree\n");
/* use the libast signal() function (aka sigaction) when applicable */
#if _map_libc || (!_std_signal && _lib_sigaction && defined(SA_NOCLDSTOP))
printf("#undef signal\n");
printf("#define signal _ast_signal\n");
#endif
#if _map_libc
printf("#undef memdup\n");
printf("#define memdup _ast_memdup\n");
Expand Down Expand Up @@ -293,8 +299,6 @@ main(void)
printf("#define setenviron _ast_setenviron\n");
printf("#undef sigcritical\n");
printf("#define sigcritical _ast_sigcritical\n");
printf("#undef signal\n");
printf("#define signal _ast_signal\n");
printf("#undef sigunblock\n");
printf("#define sigunblock _ast_sigunblock\n");
printf("#undef stracmp\n");
Expand Down

0 comments on commit ad055bb

Please sign in to comment.