trick.txt

text/plain

Filename: trick.txt
Type: text/plain
Part: 0
Message: Re: [PATCH] Silence Valgrind about SelectConfigFiles()
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 46fdefebe35..c25dfa6ab47 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -1769,7 +1769,8 @@ RemoveGUCFromLists(struct config_generic *gconf)
 		slist_delete(&guc_report_list, &gconf->report_link);
 }
 
-
+#include <stdio.h>
+#include <unistd.h>
 /*
  * Select the configuration files and data directory to be used, and
  * do the initial read of postgresql.conf.
@@ -1789,7 +1790,7 @@ SelectConfigFiles(const char *userDoption, const char *progname)
 	bool		fname_is_malloced;
 	struct stat stat_buf;
 	struct config_string *data_directory_rec;
-
+	int ret;
 	/* configdir is -D option, or $PGDATA if no -D */
 	if (userDoption)
 		configdir = make_absolute_path(userDoption);
@@ -1978,6 +1979,13 @@ SelectConfigFiles(const char *userDoption, const char *progname)
 	return true;
 
 fail:
+
+	elog(WARNING, "Attach with the debugger, pid = %d\n", getpid());
+	do {
+	  ret = sleep(1);
+	} while(ret == 0);
+	elog(WARNING, "sleep() returned %d\n", ret);
+
 	free(configdir);
 
 	return false;
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index 7e1aa422332..d14be4fda2a 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
@@ -248,7 +248,7 @@
  * You should normally use MEMORY_CONTEXT_CHECKING with USE_VALGRIND;
  * instrumentation of repalloc() is inferior without it.
  */
-/* #define USE_VALGRIND */
+#define USE_VALGRIND
 
 /*
  * Define this to cause pfree()'d memory to be cleared immediately, to