Commit Graph

184 Commits

Author SHA1 Message Date
Jeff Morriss 99ce4232cb As suggested in comments in sl_alloc() and sl_free(): add a new environment
variable (WIRESHARK_DEBUG_USE_SLICES) which turns off the slab allocator and uses
g_slices instead (which can themselves be turned off by setting
G_SLICE=always-malloc).

This makes debugging problems in slab-allocated memory easier to find
(hopefully including https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8197 ).


Set WIRESHARK_DEBUG_USE_SLICES when running Valgrind on *shark.


Remove unused structure member: emem_chunk_t.org.

svn path=/trunk/; revision=47110
2013-01-16 03:34:29 +00:00
Guy Harris 8ed7a73e22 Fix a bunch of warnings.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings.

When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.

Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers.  Cast
away those warnings in some cases where an API we don't control forces
us to do so.

Enable a bunch of additional warnings by default.  Note why at least
some of the other warnings aren't enabled.

randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.

If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.

svn path=/trunk/; revision=46748
2012-12-26 05:57:06 +00:00
Anders Broman f5226f1310 From Bill Parker:
Add error handler to munmap() failure in emem.c

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7850

svn path=/trunk/; revision=45915
2012-11-05 09:04:53 +00:00
Jakub Zawadzki f68020f1e1 Revert changes to ep_ allocator, revert edt ref-counting.
svn path=/trunk/; revision=45451
2012-10-10 19:05:30 +00:00
Jakub Zawadzki 174dabeeca Fix r45445
svn path=/trunk/; revision=45446
2012-10-10 12:30:53 +00:00
Jakub Zawadzki c24a90f49e Fix bug #7814
We need to pass original pointer and length to munmap().

svn path=/trunk/; revision=45445
2012-10-10 12:24:56 +00:00
Evan Huus fd76b098a3 Temporarilly disable ep's use of chunks until the bugs are fixed.
svn path=/trunk/; revision=45444
2012-10-10 11:17:28 +00:00
Evan Huus b01f1d3762 Actually destroy chunks in emem_free_all. We lose the efficiency of re-using
them, but until I can figure out the correct logic for that (3rd try and
counting...) this at least plugs the leak.

svn path=/trunk/; revision=45412
2012-10-08 22:27:03 +00:00
Evan Huus 693ed306d3 Try to clarify some of the ifdefs in emem.c.
svn path=/trunk/; revision=45404
2012-10-08 19:43:03 +00:00
Guy Harris e6616b7c2f Rename emem_header_t to emem_pool_t to better indicate what it can be
used for - it represents a memory pool that parcels out memory from
larger allocated chunks (reducing the number of individual malloc-style
calls that are made) and that can be freed in its entirety.

svn path=/trunk/; revision=45400
2012-10-08 18:33:00 +00:00
Gerald Combs 98d7549953 We've already typedef'ed emem_header_t in emem.h. We don't have to do it
again in emem.c.

svn path=/trunk/; revision=45396
2012-10-08 17:52:42 +00:00
Evan Huus 7c5f2ec024 Write a short essay in a comment explaining the weirdness that is now the
ephemeral allocation logic.

svn path=/trunk/; revision=45392
2012-10-08 16:42:54 +00:00
Evan Huus b6f0d11c6f EDT structures now own their ep_ memory pools. This should finally clean
up the last little bits of:
- https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5284
- https://www.wireshark.org/lists/wireshark-dev/201208/msg00128.html

and possibly part of:
- https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7775

This is a fairly invasive change that required some funky work with linked
lists to avoid changing any of the public ep_* APIs, so if something breaks
blame me :)

svn path=/trunk/; revision=45389
2012-10-08 15:23:36 +00:00
Jaap Keuter c80ed42fc6 Vastly improve the debug presentation( of trees)+.
svn path=/trunk/; revision=45340
2012-10-06 14:35:59 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Jeff Morriss 42623443ed As suggested by Anatoly in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5699 :
Followup to r44844: use a better cast (intptr_t instead of long long).

svn path=/trunk/; revision=44880
2012-09-11 13:11:33 +00:00
Jeff Morriss 17e7db3bca Attempt to fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5699
and https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5979 : 

Don't cast the buffer address to int on Win32: a 64-bit address won't
fit in an integer.

svn path=/trunk/; revision=44844
2012-09-10 15:18:17 +00:00
Michael Mann 493516fd6c Convert GString to emem_strbuf_t in packet-gadu-gadu.c
Required an additional function, ep_strbuf_append_unichar, in emem module

svn path=/trunk/; revision=44564
2012-08-18 19:20:31 +00:00
Gerald Combs 5107d75c82 Try to fix a compiler warning.
svn path=/trunk/; revision=44408
2012-08-09 22:45:43 +00:00
Gerald Combs 097f33c41d Iterate over the emem_tree_*32_array key data instead of using
recursion. I've only done minimal testing but it seems to work OK.

svn path=/trunk/; revision=44401
2012-08-09 21:46:34 +00:00
Michael Mann 05a305d332 Make emem_tree_*32_array functions non-destructive. The following dissectors/files have affectively been bugfixed by the change:
packet-classicstun.c
packet-reload-framing.c (probably)
packet-reload.c
packet-sccp.c
packet-sua.c
packet-tcp.c
packet-xmcp.c
\epan\gcp.c

The following files unnecessarily recreate keys because of the previously destructive nature of emem_tree_*32_array functions:
packet-btl2cap.c
packet-nfs.c
packet-rpc.c
packet-scsi-osd.c
packet-stun.c (per Bug 7569)

These could be cleaned up, but it's not like the key recreation is burning CPU cycles.

svn path=/trunk/; revision=44380
2012-08-09 13:59:29 +00:00
Anders Broman 1ae38887b6 From Evan Huus:
Grab-bag of unused variables.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7452

svn path=/trunk/; revision=43616
2012-07-09 01:49:02 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Jeff Morriss 06bb167824 The rest of the fix for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7221
(emem alignment problems on SPARC) :

Have emem use 8-byte alignment when we need it.

Since I can't seem to write code that which reliably (across GCC versions and
optimization levels) determines if 8-byte alignment is needed for doubles,
"when" is defined as "if we're compiling for a CPU other than i386."

Windows doesn't need a check because it's either i386 or 64-bit (x86_64 or
maybe ia64--both of which get 8-byte alignment from G_MEM_ALIGN).

(And, yes, all of this is ignoring the 16-byte alignment requirements of long
doubles.)

svn path=/trunk/; revision=42431
2012-05-04 21:56:32 +00:00
Jeff Morriss 652349d0a5 Partial fix for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7221
(emem alignment problems on SPARC) :

Add the room for the pointer to the next (from r31577) *before* calculating
the canary+pad: that way the complete allocation
(allocation+canary_ptr+canary+pad) will end on an 8-byte boundary (as was the
case before r31577).

This only solves the alignment problem when using canaries (i.e., not, by
default, se_ allocations).

(And, yes, this is ignoring the 16-byte alignment requirements of long
doubles.)

svn path=/trunk/; revision=42407
2012-05-04 01:33:58 +00:00
Jakub Zawadzki 4f3e8427f3 Revert r42001
svn path=/trunk/; revision=42013
2012-04-10 20:58:14 +00:00
Jakub Zawadzki 743fe89dc7 If scrubbing memory is set, during alloc we can check if memory is still scrubbed.
This should at least show problems with ep_ use in packet-infiband.c

svn path=/trunk/; revision=42001
2012-04-09 22:31:41 +00:00
Jeff Morriss a94c84d34f 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
2012-03-19 02:00:42 +00:00
Bill Meier 781129806f Fix ex "modeline" so it works;
See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5748

svn path=/trunk/; revision=39081
2011-09-21 17:49:11 +00:00
Jakub Zawadzki 17f6352c2e Convert SLAB_-s, to sl_-API.
svn path=/trunk/; revision=37030
2011-05-09 12:52:55 +00:00
Jakub Zawadzki 99351cb0e3 Initial commit of slab allocator (sl_* API)
svn path=/trunk/; revision=37027
2011-05-09 08:55:35 +00:00
Jakub Zawadzki 19ee373ba9 Cleanup emem_verify_pointer()
svn path=/trunk/; revision=36800
2011-04-22 12:25:01 +00:00
Guy Harris 384d06a027 Either the buf argument to emem_scrub_memory() is properly aligned or it
isn't.  If it is, we don't need to worry about alignment, so the XXX
comment doesn't belong there; if it isn't, then we should do what the
comment says.  For now, assume the comment before the XXX comment is
correct, and just cast away the alignment warning.

svn path=/trunk/; revision=36795
2011-04-22 04:01:30 +00:00
Jakub Zawadzki 27f92a4c11 Fix ep_check_canary_integrity to use proper variable.
Previously it would sigsegv (accessing (void *) -1), instead of displaying error.


svn path=/trunk/; revision=36745
2011-04-21 05:31:11 +00:00
Jeff Morriss 3161977bf8 Introduce ep_strconcat (copied from the glib version)
svn path=/trunk/; revision=36344
2011-03-26 02:39:04 +00:00
Jeff Morriss b838995e60 Remove some duplicated string manipulation code.
svn path=/trunk/; revision=36343
2011-03-26 02:11:42 +00:00
Jeff Morriss 06aaf02fba Clean up comments: canaries are also used to pad allocations to an 8-byte boundary.
svn path=/trunk/; revision=36071
2011-02-25 15:49:28 +00:00
Jeff Morriss 16f704d831 Add a comment explaining what the canary between allocations looks like.
svn path=/trunk/; revision=36065
2011-02-25 03:18:02 +00:00
Gerald Combs a6bbdaa849 Fix some dead code and zero division issues found by Clang scan-build.
In convert_string_case() use g_utf8_strup() instead of converting each
character by hand. Hopefully this won't cause any unexpected changes in
behavior.

svn path=/trunk/; revision=36006
2011-02-18 22:43:48 +00:00
Stephen Fisher 9c28650e67 Fix bug #5463 (and likely others) so that ep_strbuf_new() no longer
truncates newly created and copied strings.  The problem was that
strlen() (which returns a length not counting the NULL terminator) was
being mixed with functions that do malloc() (which need to allocate
memory large enough to inculde the NULL string terminator).


svn path=/trunk/; revision=35128
2010-12-06 17:30:08 +00:00
Jeff Morriss 7d20440ff0 Introduce 2 new environment variables: WIRESHARK_EP_VERIFY_POINTERS and
WIRESHARK_SE_VERIFY_POINTERS that control whether or not we verify if a given
pointer is ep_ or se_ allocated, respectively.

Turn the behavior off by default for speed reasons (the speed difference isn't
huge, but...).

Turn the behavior on when fuzz testing.

Document these two new variables in the man pages.

svn path=/trunk/; revision=34046
2010-09-02 18:02:06 +00:00
Guy Harris 60d5efc2a3 In C, foo() isn't a function with no arguments, foo(void) is.
svn path=/trunk/; revision=32422
2010-04-08 02:26:56 +00:00
Stig Bjørlykke f57d6e2095 From Alex Lindberg via bug 4463:
Added se_tree_lookup32_array_le to emem.[ch].  This function is similar to
se_tree_lookup32_le already defined.

Updated README.binarytrees to reflect this added function and corrected minor
spelling issues.

svn path=/trunk/; revision=31812
2010-02-07 11:01:13 +00:00
Anders Broman 8c07e34123 Reversion of SVN 30488 as suggested in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4450.
"g_strlcpy() assumes that src *IS* ASCII NUL terminated.  If the src buffer is
not NUL terminated, g_strlcpy() *WILL* read past the end of the buffer."

svn path=/trunk/; revision=31782
2010-02-04 06:42:04 +00:00
Bill Meier 9d663d7081 Fix various gcc -Wshadow warnings.
svn path=/trunk/; revision=31720
2010-01-28 18:45:46 +00:00
Anders Broman db64e65ec2 From Jakub Zawadzki:
mmap() actually when fail returns MAP_FAILED (-1) not NULL
Part of Bug:
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4140

svn path=/trunk/; revision=31593
2010-01-20 20:26:01 +00:00
Anders Broman 27bc3e2211 From Jakub Zawadzki:
Fix some bugs after merge.
Part of Bug:
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4140

svn path=/trunk/; revision=31586
2010-01-20 06:37:56 +00:00
Ronnie Sahlberg f817636cc6 remove an unusued variable
svn path=/trunk/; revision=31582
2010-01-20 03:55:03 +00:00
Anders Broman 2183430a29 From Jakub Zawadzki:
Embed canary list inside chunk data.
Part of Bug:
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4140

svn path=/trunk/; revision=31577
2010-01-19 21:28:48 +00:00
Anders Broman 46501fd7f6 From Jakub Zawadzki:
Make emem_create_chunk() a function.
Part of Bug:
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4140

svn path=/trunk/; revision=31576
2010-01-19 20:54:27 +00:00