aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add 2012 to FSF copyright years for Emacs filesGlenn Morris2012-01-051-1/+1
|
* Spelling fixes.Paul Eggert2011-12-111-1/+1
|
* Merge from trunk.Paul Eggert2011-11-191-2/+2
|\
| * Fix typos.Juanma Barranquero2011-11-151-1/+1
| |
| * Spelling fixes.Paul Eggert2011-11-141-1/+1
| |
* | Standardize on VIRT_ADDR_VARIES behavior; otherwise, valgrindPaul Eggert2011-11-101-7/+1
|/ | | | | | | | | | | | | | | | | | does not work on some platforms. Problem reported by Andreas Schwab in <http://lists.gnu.org/archive/html/emacs-devel/2011-11/msg00081.html>. * puresize.h (pure, PURE_P): Always behave as if VIRT_ADDR_VARIES is set, removing the need for VIRT_ADDRESS_VARIES. (PURE_P): Use a more-efficient implementation that needs just one comparison, not two: on x86-64 with GCC 4.6.2, this cut down the number of instructions from 6 (xorl, cmpq, jge, xorl, cmpq, setge) to 4 (xorl, subq, cmpq, setbe). * alloc.c (pure): Always extern now, since that's the VIRT_ADDR_VARIES behavior. (PURE_POINTER_P): Use a single comparison, not two, for consistency with the new puresize.h. * lisp.h (PNTR_COMPARISON_TYPE): Remove; no longer needed. * m/ibms390.h, m/intel386.h, m/template.h, s/cygwin.h, s/hpux10-20.h: Remove VIRT_ADDR_VARIES no longer needed.
* * alloc.c (DEADP): New macro, for porting to GNU/Hurd (Bug#9926).Paul Eggert2011-11-061-1/+6
| | | | | | This is also needed for porting to any host where GC_MARK_STACK is not GC_MAKE_GCPROS_NOOPS. (which_symbols): Use it.
* * alloc.c (which_symbols): Declare EXTERNALLY_VISIBLE,Paul Eggert2011-10-291-1/+2
| | | | | so that this new function doesn't get optimized away by a whole-program optimizer. Make the 2nd arg EMACS_INT, not int.
* Fix the `xbytecode' user-defined command in .gdbinit.Eli Zaretskii2011-10-291-0/+49
| | | | | | | src/.gdbinit (xprintbytestr): New command. (xwhichsymbols): Renamed from `which'; all callers changed. (xbytecode): Print the byte-code string as well. src/alloc.c (which_symbols): New function.
* * alloc.c (Fgc_status): Do not access beyond zombies arrayDmitry Antipov2011-10-111-2/+2
| | | | | boundary if nzombies > MAX_ZOMBIES. * alloc.c (dump_zombies): Add missing format specifier.
* * alloc.c: Add comment.Paul Eggert2011-10-071-0/+5
|
* Fix alignment-related core dump during GC.Paul Eggert2011-10-071-20/+17
| | | | | | | | | | | | | | * configure.in (GC_LISP_OBJECT_ALIGNMENT): Remove. This is now done by src/alloc.c. * src/alloc.c (GC_LISP_OBJECT_ALIGNMENT): Use offsetof, not __alignof__ or sizeof. __alignof__ gives the wrong answer on Fedora x86-64 with GCC 4.6.1 when configured with CC='gcc -m32' --with-wide-int; this makes Emacs dump core during garbage collection on rare occasions. sizeof is obviously inferior to offsetof here, so stick with offsetof. (GC_POINTER_ALIGNMENT): New macro. (mark_memory): Omit 3rd (offset) arg; caller changed. Don't assume EMACS_INT alignment is the same as pointer alignment.
* Remove dependency on glibc malloc internals.Paul Eggert2011-09-301-2/+45
| | | | | | | | | | | | | | | * alloc.c (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE): Move back here from lisp.h, but with their new implementations. (XMALLOC_BASE_ALIGNMENT, COMMON_MULTIPLE, XMALLOC_HEADER_ALIGNMENT) (XMALLOC_OVERRUN_SIZE_SIZE): Move these new lisp.h macros here. * charset.c (charset_table_init): New static var. (syms_of_charset): Use it instead of xmalloc. This removes a dependency on glibc malloc internals. See Eli Zaretskii's comment in <http://lists.gnu.org/archive/html/emacs-devel/2011-09/msg00815.html>. * lisp.h (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE): Move back to alloc.c. (XMALLOC_BASE_ALIGNMENT, COMMON_MULTIPLE, XMALLOC_HEADER_ALIGNMENT) (XMALLOC_OVERRUN_SIZE_SIZE): Move to alloc.c.
* Port --enable-checking=all to Fedora 14 x86.Paul Eggert2011-09-291-32/+15
| | | | | | | | | | | | | | | | | | | * alloc.c (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE): Move to lisp.h. (xmalloc_put_size, xmalloc_get_size, overrun_check_malloc) (overrun_check_realloc, overrun_check_free): Use XMALLOC_OVERRUN_SIZE_SIZE, not sizeof (size_t). That way, xmalloc returns a properly-aligned pointer even if XMALLOC_OVERRUN_CHECK is defined. The old debugging code happened to align OK on typical 64-bit hosts, but not on Fedora 14 x86. * charset.c (syms_of_charset): Take XMALLOC_OVERRUN_CHECK_OVERHEAD into account when calculating the initial malloc maximum. * lisp.h (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE): Move here from alloc.c, so that charset.c can use it too. Properly align; the old code wasn't right for common 32-bit hosts when configured with --enable-checking=all. (XMALLOC_BASE_ALIGNMENT, COMMON_MULTIPLE, XMALLOC_HEADER_ALIGNMENT) (XMALLOC_OVERRUN_SIZE_SIZE): New macros.
* Whitespace changes.Juanma Barranquero2011-09-091-11/+11
|
* Merge from trunk.Paul Eggert2011-08-041-8/+10
|\
| * Check for pthread and use it if found.Jan Djärv2011-08-041-8/+10
| | | | | | | | | | | | | | | | | | | | | | * configure.in (HAVE_PTHREAD): Add check for -lpthread. (HAVE_GTK_AND_PTHREAD): Remove. * src/Makefile.in (LIB_PTHREAD): New variable. (LIBES): Add LIB_PTHREAD (Bug#9216). * src/alloc.c, src/emacs.c, src/gmalloc.c, src/gtkutil.c, src/keyboard.c, src/syssignal.h: Rename HAVE_GTK_AND_PTHREAD to HAVE_PTHREAD (Bug#9216).
* | Adjust in response to jan.h.d's comments.Paul Eggert2011-08-041-0/+88
|/ | | | See, for example <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9196#26>.
* * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race.Paul Eggert2011-07-281-1/+5
| | | | | Without this fix, if a signal arrives just after memory fills up, 'malloc' might be invoked reentrantly.
* Merge from trunk.Paul Eggert2011-07-191-5/+5
|\
| * * alloc.c (valid_pointer_p): Use pipe, not open.Paul Eggert2011-07-181-5/+5
| | | | | | | | This fixes some permissions issues when debugging.
* | * alloc.c (__malloc_size_t): Remove.Paul Eggert2011-07-141-9/+4
| | | | | | | | | | All uses replaced by size_t. See Andreas Schwab's note <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9079#8>.
* | Merge from trunk.Paul Eggert2011-07-121-1/+1
|\ \ | |/
| * * alloc.c (gc_sweep): Don't read past end of array.Paul Eggert2011-07-121-1/+1
| | | | | | | | | | In theory, the old code could also have corrupted Emacs internals, though it'd be very unlikely.
* | Merge from trunk.Paul Eggert2011-07-101-1/+1
|\ \ | |/
| * ProtoizeAndreas Schwab2011-07-101-1/+1
| | | | | | | | | | | | * src/alloc.c (reset_malloc_hooks): Protoize. * src/cm.c (losecursor): Likewise. * src/ralloc.c (r_alloc_check): Likewise.
* | * alloc.c: Integer signedness and overflow fixes.Paul Eggert2011-07-071-58/+78
|/ | | | | | | | | | | | | | | | | | | | | | | | | Do not impose an arbitrary 32-bit limit on malloc sizes when debugging. (__malloc_size_t): Default to size_t, not to int. (pure_size, pure_bytes_used_before_overflow, stack_copy_size) (Fgarbage_collect, mark_object_loop_halt, mark_object): Prefer ptrdiff_t to size_t when either would do, as we prefer signed integers. (XMALLOC_OVERRUN_CHECK_OVERHEAD): New macro. (xmalloc_overrun_check_header, xmalloc_overrun_check_trailer): Now const. Initialize with values that are in range even if char is signed. (XMALLOC_PUT_SIZE, XMALLOC_GET_SIZE): Remove, replacing with ... (xmalloc_put_size, xmalloc_get_size): New functions. All uses changed. These functions do the right thing with sizes > 2**32. (check_depth): Now ptrdiff_t, not int. (overrun_check_malloc, overrun_check_realloc, overrun_check_free): Adjust to new way of storing sizes. Check for size overflow bugs in rest of code. (STRING_BYTES_MAX): Adjust to new overheads. The old code was slightly wrong anyway, as it missed one instance of XMALLOC_OVERRUN_CHECK_OVERHEAD. (refill_memory_reserve): Omit needless cast to size_t. (mark_object_loop_halt): Mark as externally visible.
* Remove more assumptions re struct layout (Bug#8884).Paul Eggert2011-07-061-1/+2
|
* Move DEFSYM to lisp.h and use everywhere.Juanma Barranquero2011-06-241-7/+3
|
* * alloc.c (Fmake_bool_vector): Avoid unnecessary multiplication.Paul Eggert2011-06-181-5/+7
|
* * alloc.c: Check that resized vectors' lengths fit in fixnums.Paul Eggert2011-06-141-10/+15
| | | | | | | | (header_size, word_size): New constants. (allocate_vectorlike): Don't check size overflow here. (allocate_vector): Check it here instead, since this is the only caller of allocate_vectorlike that could cause overflow. Check that the new vector's length is representable as a fixnum.
* Variadic C functions now count arguments with ptrdiff_t.Paul Eggert2011-06-141-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | This partly undoes my 2011-03-30 change, which replaced int with size_t. Back then I didn't know that the Emacs coding style prefers signed int. Also, in the meantime I found a few more instances where arguments were being counted with int, which may truncate counts on 64-bit machines, or EMACS_INT, which may be unnecessarily wide. * lisp.h (struct Lisp_Subr.function.aMANY) (DEFUN_ARGS_MANY, internal_condition_case_n, safe_call): Arg counts are now ptrdiff_t, not size_t. All variadic functions and their callers changed accordingly. (struct gcpro.nvars): Now size_t, not size_t. All uses changed. * bytecode.c (exec_byte_code): Check maxdepth for overflow, to avoid potential buffer overrun. Don't assume arg counts fit in 'int'. * callint.c (Fcall_interactively): Check arg count for overflow, to avoid potential buffer overrun. Use signed char, not 'int', for 'varies' array, so that we needn't bother to check its size calculation for overflow. * editfns.c (Fformat): Use ptrdiff_t, not EMACS_INT, to count args. * eval.c (apply_lambda): * fns.c (Fmapconcat): Use XFASTINT, not XINT, to get args length. (struct textprop_rec.argnum): Now ptrdiff_t, not int. All uses changed. (mapconcat): Use ptrdiff_t, not int and EMACS_INT, to count args.
* * lisp.h (SAFE_ALLOCA_LISP): Check for integer overflow.Paul Eggert2011-06-081-2/+2
| | | | | | | | | (struct Lisp_Save_Value): Use ptrdiff_t, not int, for 'integer' member. * alloc.c (make_save_value): Integer argument is now of type ptrdiff_t, not int. (mark_object): Use ptrdiff_t, not int. * lisp.h (pD): New macro. * print.c (print_object): Use it.
* * alloc.c (allocate_pseudovector): Don't use EMACS_INT when int would do.Paul Eggert2011-06-081-1/+1
|
* * alloc.c (inhibit_garbage_collection): Set gc_cons_threshold to max value.Paul Eggert2011-06-081-2/+1
| | | | | Previously, this ceilinged at INT_MAX, but that doesn't work on 64-bit machines.
* * alloc.c (nzombies, ngcs, max_live, max_zombies): Now EMACS_INT, not 'int'.Paul Eggert2011-06-081-5/+5
|
* * alloc.c: (n_interval_blocks, n_string_blocks, n_float_blocks, n_cons_blocks)Paul Eggert2011-06-081-46/+1
| | | | | | (n_vectors, n_symbol_blocks, n_marker_blocks): Remove. These were 'int' variables that could overflow on 64-bit hosts; they were never used, so remove them instead of repairing them.
* * alloc.c: Use EMACS_INT, not int, to count objects.Paul Eggert2011-06-081-14/+20
| | | | | | | | | | | (total_conses, total_markers, total_symbols, total_vector_size) (total_free_conses, total_free_markers, total_free_symbols) (total_free_floats, total_floats, total_free_intervals, total_intervals) (total_strings, total_free_strings): Now EMACS_INT, not int. All uses changed. (Fgarbage_collect): Compute overall total using a double, so that integer overflow is less likely to be a problem. Check for overflow when converting back to an integer.
* * alloc.c (mark_vectorlike, mark_char_table, mark_object): Avoid EMACS_UINTPaul Eggert2011-06-081-7/+6
| | | | | when a (possibly-narrower) signed value would do just as well. We prefer using signed arithmetic, to avoid comparison confusion.
* * alloc.c (allocate_vectorlike): Check for ptrdiff_t overflow.Paul Eggert2011-06-081-1/+2
|
* * alloc.c (Fmake_bool_vector): Don't assume vector size fits in int.Paul Eggert2011-06-081-4/+1
|
* * alloc.c: Catch some string size overflows that we were missing.Paul Eggert2011-06-081-1/+18
| | | | | | | | | | | | | | | (XMALLOC_OVERRUN_CHECK_SIZE) [!XMALLOC_OVERRUN_CHECK]: Define to 0, for convenience in STRING_BYTES_MAX. (STRING_BYTES_MAX): New macro, superseding the old one in lisp.h. The definition here is exact; the one in lisp.h was approximate. (allocate_string_data): Check for string overflow. This catches some instances we weren't catching before. Also, it catches size_t overflow on (unusual) hosts where SIZE_MAX <= min (PTRDIFF_MAX, MOST_POSITIVE_FIXNUM), e.g., when size_t is 32 bits and ptrdiff_t and EMACS_INT are both 64 bits. * character.c, coding.c, doprnt.c, editfns.c, eval.c: All uses of STRING_BYTES_MAX replaced by STRING_BYTES_BOUND. * lisp.h (STRING_BYTES_BOUND): Renamed from STRING_BYTES_MAX.
* * alloc.c (Fmake_string): Check for out-of-range init.Paul Eggert2011-06-061-2/+2
|
* Merge from trunk.Paul Eggert2011-06-061-11/+4
|\
| * * alloc.c: Simplify handling of large-request failures (Bug#8800).Paul Eggert2011-06-061-11/+4
| | | | | | | | | | | | (SPARE_MEMORY): Always define. (LARGE_REQUEST): Remove. (memory_full): Use SPARE_MEMORY rather than LARGE_REQUEST.
* | Check for buffer and string overflow more precisely.Paul Eggert2011-06-051-1/+1
|/ | | | | | | | | | | | | | | | * buffer.h (BUF_BYTES_MAX): New macro. * lisp.h (STRING_BYTES_MAX): New macro. * alloc.c (Fmake_string): * character.c (string_escape_byte8): * coding.c (coding_alloc_by_realloc): * doprnt.c (doprnt): * editfns.c (Fformat): * eval.c (verror): Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM, since they may not be the same number. * editfns.c (Finsert_char): * fileio.c (Finsert_file_contents): Likewise for BUF_BYTES_MAX.
* * alloc.c (memory_full) [SYSTEM_MALLOC]: Port to MacO).Paul Eggert2011-06-051-6/+9
| | | | Fixes: debbugs:8800
* * alloc.c (allocate_vectorlike): Adjust to memory_full API change.Paul Eggert2011-06-021-1/+1
|
* Merge from trunk.Paul Eggert2011-06-021-3/+7
|\
| * Remove arbitrary limit of 2**31 entries in hash tables.Paul Eggert2011-05-301-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * category.c (hash_get_category_set): Use 'EMACS_UINT' and 'EMACS_INT' for hashes and hash indexes, instead of 'unsigned' and 'int'. * ccl.c (ccl_driver): Likewise. * charset.c (Fdefine_charset_internal): Likewise. * charset.h (struct charset.hash_index): Likewise. * composite.c (get_composition_id, gstring_lookup_cache): (composition_gstring_put_cache): Likewise. * composite.h (struct composition.hash_index): Likewise. * dispextern.h (struct image.hash): Likewise. * fns.c (next_almost_prime, larger_vector, cmpfn_eql): (cmpfn_equal, cmpfn_user_defined, hashfn_eq, hashfn_eql): (hashfn_equal, hashfn_user_defined, make_hash_table): (maybe_resize_hash_table, hash_lookup, hash_put): (hash_remove_from_table, hash_clear, sweep_weak_table, SXHASH_COMBINE): (sxhash_string, sxhash_list, sxhash_vector, sxhash_bool_vector): (Fsxhash, Fgethash, Fputhash, Fmaphash): Likewise. * image.c (make_image, search_image_cache, lookup_image): (xpm_put_color_table_h): Likewise. * lisp.h (struct Lisp_Hash_Table): Likewise, for 'count', 'cmpfn', and 'hashfn' members. * minibuf.c (Ftry_completion, Fall_completions, Ftest_completion): Likewise. * print.c (print): Likewise. * alloc.c (allocate_vectorlike): Check for overflow in vector size calculations. * ccl.c (ccl_driver): Check for overflow when converting EMACS_INT to int. * fns.c, image.c: Remove unnecessary static decls that would otherwise need to be updated by these changes. * fns.c (make_hash_table, maybe_resize_hash_table): Check for integer overflow with large hash tables. (make_hash_table, maybe_resize_hash_table, Fmake_hash_table): Prefer the faster XFLOAT_DATA to XFLOATINT where either will do. (SXHASH_REDUCE): New macro. (sxhash_string, sxhash_list, sxhash_vector, sxhash_bool_vector): Use it instead of discarding useful hash info with large hash values. (sxhash_float): New function. (sxhash): Use it. No more need for "& INTMASK" due to above changes. * lisp.h (FIXNUM_BITS): New macro, useful for SXHASH_REDUCE etc. (MOST_NEGATIVE_FIXNUM, MOST_POSITIVE_FIXNUM, INTMASK): Rewrite to use FIXNUM_BITS, as this simplifies things. (next_almost_prime, larger_vector, sxhash, hash_lookup, hash_put): Adjust signatures to match updated version of code. (consing_since_gc): Now EMACS_INT, since a single hash table can use more than INT_MAX bytes.