[Asterisk-code-review] core: Backport compatible MALLOC DEBUG changes. (asterisk[15])

Jenkins2 asteriskteam at digium.com
Mon Mar 19 10:35:11 CDT 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8525 )

Change subject: core: Backport compatible MALLOC_DEBUG changes.
......................................................................

core: Backport compatible MALLOC_DEBUG changes.

* Add support for MALLOC_DEBUG and DEBUG_CHAOS to be used together.
* Add utils/astmm.c to .gitignore.
* Fix MALLOC_DEBUG variant of __ast_vasprintf.  This function called
  va_end(ap) upon allocation failure.  This is incorrect since ap is
  passed as an argument.

Change-Id: I9f27ced4ce3cbe4b39547a67f994fdff491978c0
---
M build_tools/cflags.xml
M main/astmm.c
M utils/.gitignore
3 files changed, 3 insertions(+), 3 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml
index f05f428..c4f9458 100644
--- a/build_tools/cflags.xml
+++ b/build_tools/cflags.xml
@@ -78,11 +78,9 @@
 			<support_level>extended</support_level>
 		</member>
 		<member name="MALLOC_DEBUG" displayname="Keep Track of Memory Allocations">
-			<conflict>DEBUG_CHAOS</conflict>
 			<support_level>core</support_level>
 		</member>
 		<member name="DEBUG_CHAOS" displayname="Randomly FAIL memory allocations or other operations">
-			<conflict>MALLOC_DEBUG</conflict>
 			<support_level>core</support_level>
 		</member>
 		<member name="ADDRESS_SANITIZER" displayname="Address Sanitizer">
diff --git a/main/astmm.c b/main/astmm.c
index accd2ff..3a07f39 100644
--- a/main/astmm.c
+++ b/main/astmm.c
@@ -216,6 +216,8 @@
 	unsigned int *fence;
 	int hash;
 
+	DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
+
 	if (!(reg = malloc(size + sizeof(*reg) + sizeof(*fence)))) {
 		astmm_log("Memory Allocation Failure - '%d' bytes at %s %s() line %d\n",
 			(int) size, file, func, lineno);
@@ -653,7 +655,6 @@
 	size = vsnprintf(&s, 1, fmt, ap2);
 	va_end(ap2);
 	if (!(*strp = __ast_alloc_region(size + 1, FUNC_VASPRINTF, file, lineno, func, 0))) {
-		va_end(ap);
 		return -1;
 	}
 	vsnprintf(*strp, size + 1, fmt, ap);
diff --git a/utils/.gitignore b/utils/.gitignore
index dbdc6b6..7840265 100644
--- a/utils/.gitignore
+++ b/utils/.gitignore
@@ -3,6 +3,7 @@
 aelparse.c
 ast_expr2.c
 ast_expr2f.c
+astmm.c
 astman
 astcanary
 astdb2bdb

-- 
To view, visit https://gerrit.asterisk.org/8525
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I9f27ced4ce3cbe4b39547a67f994fdff491978c0
Gerrit-Change-Number: 8525
Gerrit-PatchSet: 2
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180319/94111d6e/attachment.html>


More information about the asterisk-code-review mailing list