aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2012-03-19 02:00:42 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2012-03-19 02:00:42 +0000
commita94c84d34f3770037047e80d3fe1c047d3960016 (patch)
tree128958c70d4a42ba9c5c046387b5538f77a86950
parent13e113bd44573ac03ba9ded673eeda25c418348e (diff)
Add a new environment variable (WIRESHARK_ABORT_ON_OUT_OF_MEMORY) that
prevents OutOfMemory exceptions from being thrown. This makes it easier to debug such conditions. Set this variable in test-fuzzed-cap.sh but not in fuzz-test.sh; it's nice to see the friendly out-of-memory error message in the bug reports the latter script generates. svn path=/trunk/; revision=41656
-rw-r--r--doc/rawshark.pod13
-rw-r--r--doc/tshark.pod13
-rw-r--r--doc/wireshark.pod.template13
-rw-r--r--epan/emem.c10
-rwxr-xr-xtools/test-fuzzed-cap.sh3
5 files changed, 41 insertions, 11 deletions
diff --git a/doc/rawshark.pod b/doc/rawshark.pod
index 71196e82ce..f96affdd3a 100644
--- a/doc/rawshark.pod
+++ b/doc/rawshark.pod
@@ -418,7 +418,7 @@ This comes at the expense of significant extra memory usage.
=item WIRESHARK_DEBUG_SCRUB_MEMORY
-If this environment variable is exported, the contents of per-packet and
+If this environment variable is set, the contents of per-packet and
per-file memory is initialized to 0xBADDCAFE when the memory is allocated
and is reset to 0xDEADBEEF when the memory is freed. This functionality is
useful mainly to developers looking for bugs in the way memory is handled.
@@ -469,18 +469,25 @@ with a protocol dissector.
=item WIRESHARK_EP_VERIFY_POINTERS
-This environment variable, if exported, causes certain uses of pointers to be
+This environment variable, if set, causes certain uses of pointers to be
audited to ensure they do not point to memory that is deallocated after each
packet has been fully dissected. This can be useful to developers writing or
auditing code.
=item WIRESHARK_SE_VERIFY_POINTERS
-This environment variable, if exported, causes certain uses of pointers to be
+This environment variable, if set, causes certain uses of pointers to be
audited to ensure they do not point to memory that is deallocated after when
a capture file is closed. This can be useful to developers writing or
auditing code.
+=item WIRESHARK_ABORT_ON_OUT_OF_MEMORY
+
+This environment variable, if present, causes abort() to be called if certain
+out-of-memory conditions (which normally result in an exception and an
+explanatory error message)) are experienced. This can be useful to developers
+debugging out-of-memory conditions.
+
=back
=head1 SEE ALSO
diff --git a/doc/tshark.pod b/doc/tshark.pod
index f9f7a9c76a..82e8bd630e 100644
--- a/doc/tshark.pod
+++ b/doc/tshark.pod
@@ -1514,7 +1514,7 @@ This comes at the expense of significant extra memory usage.
=item WIRESHARK_DEBUG_SCRUB_MEMORY
-If this environment variable is exported, the contents of per-packet and
+If this environment variable is set, the contents of per-packet and
per-file memory is initialized to 0xBADDCAFE when the memory is allocated
and is reset to 0xDEADBEEF when the memory is freed. This functionality is
useful mainly to developers looking for bugs in the way memory is handled.
@@ -1565,18 +1565,25 @@ with a protocol dissector.
=item WIRESHARK_EP_VERIFY_POINTERS
-This environment variable, if exported, causes certain uses of pointers to be
+This environment variable, if present, causes certain uses of pointers to be
audited to ensure they do not point to memory that is deallocated after each
packet has been fully dissected. This can be useful to developers writing or
auditing code.
=item WIRESHARK_SE_VERIFY_POINTERS
-This environment variable, if exported, causes certain uses of pointers to be
+This environment variable, if present, causes certain uses of pointers to be
audited to ensure they do not point to memory that is deallocated after when
a capture file is closed. This can be useful to developers writing or
auditing code.
+=item WIRESHARK_ABORT_ON_OUT_OF_MEMORY
+
+This environment variable, if present, causes abort() to be called if certain
+out-of-memory conditions (which normally result in an exception and an
+explanatory error message)) are experienced. This can be useful to developers
+debugging out-of-memory conditions.
+
=back
=head1 SEE ALSO
diff --git a/doc/wireshark.pod.template b/doc/wireshark.pod.template
index 0d2424d8a3..5d5224508a 100644
--- a/doc/wireshark.pod.template
+++ b/doc/wireshark.pod.template
@@ -2724,7 +2724,7 @@ This comes at the expense of significant extra memory usage.
=item WIRESHARK_DEBUG_SCRUB_MEMORY
-If this environment variable is exported, the contents of per-packet and
+If this environment variable is set, the contents of per-packet and
per-file memory is initialized to 0xBADDCAFE when the memory is allocated
and is reset to 0xDEADBEEF when the memory is freed. This functionality is
useful mainly to developers looking for bugs in the way memory is handled.
@@ -2775,14 +2775,14 @@ with a protocol dissector.
=item WIRESHARK_EP_VERIFY_POINTERS
-This environment variable, if exported, causes certain uses of pointers to be
+This environment variable, if set, causes certain uses of pointers to be
audited to ensure they do not point to memory that is deallocated after each
packet has been fully dissected. This can be useful to developers writing or
auditing code.
=item WIRESHARK_SE_VERIFY_POINTERS
-This environment variable, if exported, causes certain uses of pointers to be
+This environment variable, if set, causes certain uses of pointers to be
audited to ensure they do not point to memory that is deallocated after when
a capture file is closed. This can be useful to developers writing or
auditing code.
@@ -2795,6 +2795,13 @@ that. You must also specify an autostop condition, e.g. B<-c> or B<-a
duration:...>. This means that you will not be able to see the results
of the capture after it stops; it's primarily useful for testing.
+=item WIRESHARK_ABORT_ON_OUT_OF_MEMORY
+
+This environment variable, if present, causes abort() to be called if certain
+out-of-memory conditions (which normally result in an exception and an
+explanatory error message)) are experienced. This can be useful to developers
+debugging out-of-memory conditions.
+
=back
=head1 SEE ALSO
diff --git a/epan/emem.c b/epan/emem.c
index 29f1e2960d..0e5478efcc 100644
--- a/epan/emem.c
+++ b/epan/emem.c
@@ -640,7 +640,10 @@ emem_create_chunk(size_t size)
if (npc->buf == NULL) {
g_free(npc);
- THROW(OutOfMemoryError);
+ if (getenv("WIRESHARK_ABORT_ON_OUT_OF_MEMORY"))
+ abort();
+ else
+ THROW(OutOfMemoryError);
}
#elif defined(USE_GUARD_PAGES)
@@ -649,7 +652,10 @@ emem_create_chunk(size_t size)
if (npc->buf == MAP_FAILED) {
g_free(npc);
- THROW(OutOfMemoryError);
+ if (getenv("WIRESHARK_ABORT_ON_OUT_OF_MEMORY"))
+ abort();
+ else
+ THROW(OutOfMemoryError);
}
#else /* Is there a draft in here? */
diff --git a/tools/test-fuzzed-cap.sh b/tools/test-fuzzed-cap.sh
index 29de7e81fc..2e98a8c9bd 100755
--- a/tools/test-fuzzed-cap.sh
+++ b/tools/test-fuzzed-cap.sh
@@ -46,6 +46,9 @@ export WIRESHARK_DEBUG_SE_USE_CANARY=
export WIRESHARK_EP_VERIFY_POINTERS=
export WIRESHARK_SE_VERIFY_POINTERS=
+# abort instead of giving a nice error message
+export WIRESHARK_ABORT_ON_OUT_OF_MEMORY=
+
# Turn on GLib memory debugging (since 2.13)
export G_SLICE=debug-blocks
# Cause glibc (Linux) to abort() if some memory errors are found