Skip to content

Commit ffcfb62

Browse files
authored
Merge pull request #8 from dtrudg/issue7
Disable Go runtime GC for starter process
2 parents 83469bd + 1137d8b commit ffcfb62

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Copyright (c) 2015-2017, Gregory M. Kurtzer. All rights reserved.
22
Copyright (c) 2016-2017, The Regents of the University of California. All right reserved.
33
Copyright (c) 2017, SingularityWare, LLC. All rights reserved.
4-
Copyright (c) 2018-2019, Sylabs, Inc. All rights reserved.
4+
Copyright (c) 2018-2021, Sylabs, Inc. All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without
77
modification, are permitted provided that the following conditions are met:

cmd/starter/c/starter.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2018-2020, Sylabs, Inc. All rights reserved.
2+
Copyright (c) 2018-2021, Sylabs, Inc. All rights reserved.
33
44
This software is licensed under a 3-clause BSD license. Please
55
consult LICENSE.md file distributed with the sources of this project regarding
@@ -986,6 +986,7 @@ static void cleanup_fd(fdlist_t *master, struct starter *starter) {
986986
if ( starter->fds[i] == fd ) {
987987
found = true;
988988
/* set force close on exec */
989+
debugf("Setting FD_CLOEXEC on starter fd %d\n", starter->fds[i]);
989990
if ( fcntl(starter->fds[i], F_SETFD, FD_CLOEXEC) < 0 ) {
990991
debugf("Can't set FD_CLOEXEC on file descriptor %d: %s\n", starter->fds[i], strerror(errno));
991992
}
@@ -1139,9 +1140,17 @@ static void cleanenv(void) {
11391140
/*
11401141
* keep only SINGULARITY_MESSAGELEVEL for GO runtime, set others to empty
11411142
* string and not NULL (see issue #3703 for why)
1143+
*
1144+
* DCT - also keep any GOGC and GODEBUG vars for go runtime
1145+
* debugging purposes.
11421146
*/
11431147
for (e = environ; *e != NULL; e++) {
1144-
if ( strncmp(MSGLVL_ENV "=", *e, sizeof(MSGLVL_ENV)) != 0 ) {
1148+
if ( strncmp(MSGLVL_ENV "=", *e, strlen(MSGLVL_ENV "=")) == 0 ||
1149+
strncmp("GOGC" "=", *e, strlen("GOGC" "=")) == 0 ||
1150+
strncmp("GODEBUG" "=", *e, strlen("GODEBUG" "=")) == 0 ) {
1151+
debugf("Keeping env var %s\n", *e);
1152+
} else {
1153+
debugf("Clearing env var %s\n", *e);
11451154
*e = "";
11461155
}
11471156
}

internal/pkg/util/starter/starter.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019-2020, Sylabs Inc. All rights reserved.
1+
// Copyright (c) 2019-2021, Sylabs Inc. All rights reserved.
22
// This software is licensed under a 3-clause BSD license. Please consult the
33
// LICENSE.md file distributed with the sources of this project regarding your
44
// rights to use or distribute this software.
@@ -89,6 +89,8 @@ func Exec(name string, config *config.Common, ops ...CommandOp) error {
8989
if err := c.init(config, ops...); err != nil {
9090
return fmt.Errorf("while initializing starter command: %s", err)
9191
}
92+
sylog.Debugf("Setting GOGC=off for starter")
93+
c.env = append(c.env, "GOGC=off")
9294
err := unix.Exec(c.path, []string{name}, c.env)
9395
return fmt.Errorf("while executing %s: %s", c.path, err)
9496
}

0 commit comments

Comments
 (0)