Ivan Maidanski [Fri, 19 Oct 2012 03:50:18 +0000 (07:50 +0400)]
Improve staticrootstest checks (tests)
* tests/staticrootstest.c (libsrl_init): Report error (and exit) if
libsrl_init returns NULL; report the corresponding error if staticroot
content is not as expected.
Ivan Maidanski [Fri, 19 Oct 2012 03:27:29 +0000 (07:27 +0400)]
Specify GC_malloc result is unused in some tests
* tests/middle.c (main): Explicitly cast result of GC_malloc[_atomic]
to void (to outline that the result is unused intentionally).
* tests/test.c (run_one_test): Likewise.
Ivan Maidanski [Fri, 19 Oct 2012 03:12:09 +0000 (07:12 +0400)]
Add comment for big local_mark_stack variables in mark.c
* mark.c (LOCAL_MARK_STACK_SIZE): Fix letter case in comment.
* mark.c (GC_do_parallel_mark, GC_help_marker): Add comment about
local_mark_stack local variable size (some static analysis tools
issue warning about it).
* mark.c (GC_help_marker): Move local_mark_stack variable declaration
down to be the last one in the function.
Ivan Maidanski [Thu, 18 Oct 2012 15:05:54 +0000 (19:05 +0400)]
Eliminate SIGBUS-related dead code in GC_write_fault_handler (Linux)
* os_dep.c (GC_old_bus_handler_used_si): Define only if
FREEBSD/HURD/HPUX (since not used otherwise).
* os_dep.c (SIG_OK): Add comment.
* os_dep.c (GC_write_fault_handler): Replace as check of "sig" value
for SIGSEGV with that of SIGBUS and do this check only if
FREEBSD/HURD/HPUX (to avoid "dead code" compiler warning).
* os_dep.c (GC_dirty_init): Do not set GC_old_bus_handler_used_si
for LINUX (since used only on FREEBSD/HURD/HPUX); do not fix
GC_old_bus_handler value in case it is SIG_IGN for LINUX; add comment.
Ivan Maidanski [Thu, 18 Oct 2012 05:35:46 +0000 (09:35 +0400)]
Remove nested always-false ifdef for HPUX and FREEBSD
* include/private/gcconfig.h (USE_HPUX_FIXED_STACKBOTTOM): Add missing
dot in comment.
* os_dep.c (old_bus_act, GC_set_and_save_fault_handler,
GC_reset_fault_handler): Remove false ifdef check for HPUX and FREEBSD
inside ifdef for SUNOS5SIGS, IRIX5, OSF1, HURD, or NETBSD.
Ivan Maidanski [Thu, 18 Oct 2012 04:50:36 +0000 (08:50 +0400)]
Define old_bus_handler static variable only if used (Unix)
* os_dep.c (old_bus_handler): Define only if SIGBUS (only for
UNIX_LIKE or NEED_FIND_LIMIT).
Ivan Maidanski [Wed, 17 Oct 2012 18:07:54 +0000 (22:07 +0400)]
Fix vsprintf_args cleanup in CORD_vsprintf
* cord/cordprnt.c (CORD_vsprintf): Invoke va_end (before return) for
vsprintf_args initialized by [__]va_copy (only if __va_copy defined
or GCC but not DJGPP).
Ivan Maidanski [Wed, 17 Oct 2012 17:58:38 +0000 (21:58 +0400)]
Minor code refactoring of GC_allochblk_nth
* allchblk.c (GC_allochblk_nth): Simplify code in the loop (which
allocates and drops the block in small chunks) by first calling
GC_install_header if h != hbp (instead of calling it a conditional
expression) and, then, calling setup_header if hhdr is non-NULL.
Ivan Maidanski [Wed, 17 Oct 2012 17:44:24 +0000 (21:44 +0400)]
Add comment for _DYNAMIC[] compared to NULL in GC_FirstDLOpenedLinkMap
* dyn_load.c (GC_FirstDLOpenedLinkMap): Add comment for
_DYNAMIC-is-NULL code branch; cast _DYNAMIC (array symbol) to ptr_t
in comparison to NULL (0).
Ivan Maidanski [Wed, 17 Oct 2012 17:34:33 +0000 (21:34 +0400)]
Add comment about sigaction sa_restorer field
* os_dep.c (GC_find_limit_openbsd, GC_skip_hole_openbsd,
GC_set_and_save_fault_handler, GC_dirty_init): Add comment about
sigaction sa_restorer field initialization (some static code analysis
tools report about uninitialized field but according to Linux manual
it is obsolete and should not be used).
* pthread_stop_world.c (GC_stop_init): Likewise.
Ivan Maidanski [Wed, 17 Oct 2012 17:21:11 +0000 (21:21 +0400)]
Fix sizeof in GC_push_thread_structures
* pthread_support.c (GC_push_thread_structures): Fix sizeof argument
(take size of GC_thread_key variable instead of its address) if
THREAD_LOCAL_ALLOC.
* win32_threads.c (GC_push_thread_structures): Likewise.
Ivan Maidanski [Tue, 9 Oct 2012 18:20:48 +0000 (22:20 +0400)]
Fix GC_CreateThread and GC_beginthreadex definition for Cygwin
* win32_threads.c (CreateThread, ExitThread, _beginthreadex,
_endthreadex): Undefine unconditionally (because the original function
might be used even for GC_PTHREADS targets).
* win32_threads.c (GC_beginthreadex, GC_endthreadex): Do not define
on Cygwin because the latter does not provide _beginthreadex and
_endthreadex.
Ivan Maidanski [Sat, 29 Sep 2012 10:07:55 +0000 (14:07 +0400)]
Port BDWGC to Android/x86
* include/private/gc_priv.h (SETJMP, LONGJMP, JMP_BUF): Explicitly
define to setjmp/longjmp/jmp_buf (instead of
sigsetjmp/siglongjmp/sigjmp_buf), respectively, if GC_NO_SIGSETJMP.
* include/private/gcconfig.h (GC_NO_SIGSETJMP): New macro, define for
Android/x86.
* include/private/gcconfig.h (NO_GETCONTEXT): define for Android/x86
(since getcontext is missing in Android).
Ivan Maidanski [Sat, 29 Sep 2012 09:13:01 +0000 (13:13 +0400)]
Move 'include setjmp.h' from mach_dep.c to gc_priv.h
* include/private/gc_priv.h: Include setjmp.h unconditionally (since
SETJMP/LONGJMP is always defined).
* mach_dep.c: Remove redundant include setjmp.h.
Ivan Maidanski [Sat, 29 Sep 2012 08:27:39 +0000 (12:27 +0400)]
Fix a typo in comment of GC_with_callee_saves_pushed
* mach_dep.c (GC_with_callee_saves_pushed): Fix a typo in comment.
Ivan Maidanski [Sat, 29 Sep 2012 08:23:40 +0000 (12:23 +0400)]
Do not define _setjmp/_longjmp macros in mach_dep.c (code refactoring)
* mach_dep.c (_setjmp, _longjmp): Remove unused macro definition (if
OS2, or CX_UX or __CC_ARM).
* mach_dep.c (GC_with_callee_saves_pushed): Use setjmp instead of
_setjmp also for OS2, CX_UX and __CC_ARM.
Ivan Maidanski [Tue, 18 Sep 2012 11:47:36 +0000 (15:47 +0400)]
tests: Log error messages to stderr instead of stdout
* tests/initsecondarythread.c (main): Print error messages using
fprintf(stderr) instead of printf().
* tests/subthread_create.c (entry, main): Likewise.
* tests/thread_leak_test.c (main): Likewise.
* tests/trace_test.c (mktree): Likewise.
* tests/thread_leak_test.c (main): Call exit(2) if thread creation or
joining failed.
Ivan Maidanski [Tue, 18 Sep 2012 10:32:40 +0000 (14:32 +0400)]
Update ChangeLog file
Ivan Maidanski [Wed, 12 Sep 2012 05:46:41 +0000 (09:46 +0400)]
Eliminate 'unused value' compiler warning in GC_stop_world (Pthreads)
* pthread_stop_world.c (GC_stop_world): Eliminate
"assigned value never used" compiler warning for "code" local variable
in conditional statement checking sem_wait result.
Ivan Maidanski [Tue, 11 Sep 2012 19:55:32 +0000 (23:55 +0400)]
Fix null-pointer dereference in CORD_substr_closure
* cord/cordbscs.c (CORD_substr_closure): Prevent SEGV if CORD_from_fn
returned NULL/CORD_EMPTY (in case "n" argument is zero).
Ivan Maidanski [Tue, 11 Sep 2012 19:23:13 +0000 (23:23 +0400)]
Fix min_bytes_allocd comment
* alloc.c (min_bytes_allocd): Fix comment (replace "words" with
"bytes").
Ivan Maidanski [Tue, 11 Sep 2012 19:13:06 +0000 (23:13 +0400)]
Remove nested EXPECT in GC_core_finalized_malloc
* fnlz_mlc.c (GC_core_finalized_malloc): Remove duplicate (nested)
EXPECT for SMALL_OBJ (since the latter already contains the former).
Ivan Maidanski [Tue, 11 Sep 2012 19:03:55 +0000 (23:03 +0400)]
Enable 'Force GC at every GC_malloc' debug-related functionality
* doc/README.environment (GC_COLLECT_AT_MALLOC): Document.
* doc/README.macros (GC_COLLECT_AT_MALLOC): Likewise.
* fnlz_mlc.c (GC_core_finalized_malloc): Insert
GC_DBG_COLLECT_AT_MALLOC invocation (before LOCK).
* gcj_mlc.c (GC_core_gcj_malloc, GC_gcj_malloc_ignore_off_page):
Likewise.
* malloc.c (GC_generic_malloc, GC_malloc_atomic, GC_malloc,
GC_malloc_uncollectable): Likewise.
* mallocx.c (GC_generic_malloc_ignore_off_page,
GC_generic_malloc_many, GC_malloc_atomic_uncollectable): Likewise.
* typd_mlc.c (GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page): Likewise.
* include/private/gc_priv.h (GC_COLLECT_AT_MALLOC): Recognize new
macro.
(GC_dbg_collect_at_malloc_min_lb): New global variable declaration
(only if GC_COLLECT_AT_MALLOC defined).
(GC_DBG_COLLECT_AT_MALLOC): Define new macro (invoking GC_gcollect).
* malloc.c (GC_dbg_collect_at_malloc_min_lb): New global variable
(only if GC_COLLECT_AT_MALLOC defined).
* misc.c (GC_init): Test "GC_COLLECT_AT_MALLOC" environment variable
and alter default GC_dbg_collect_at_malloc_min_lb value (only if
GC_COLLECT_AT_MALLOC macro defined).
Ivan Maidanski [Tue, 11 Sep 2012 04:30:25 +0000 (08:30 +0400)]
Fix min_bytes_allocd preventing potential infinite loop in GC_allocobj
* alloc.c (min_bytes_allocd): Do not return zero in case of big
GC_free_space_divisor value (return 1 instead to prevent infinite loop
in GC_allocobj if GC_adj_bytes_allocd returns zero); update comment.
Ivan Maidanski [Tue, 11 Sep 2012 04:17:59 +0000 (08:17 +0400)]
Update information about GC_free_space_divisor in README
* README (GC_free_space_divisor): Update information.
Ivan Maidanski [Sun, 9 Sep 2012 09:26:33 +0000 (13:26 +0400)]
Update ChangeLog file
Ivan Maidanski [Sun, 9 Sep 2012 08:57:38 +0000 (12:57 +0400)]
Eliminate Clang warning for GC_pthread_exit attribute
* include/gc_pthread_redirects.h (GC_PTHREAD_EXIT_DECLARED): Test and
define new macro (only if GC_PTHREAD_EXIT_ATTRIBUTE) to prevent Clang
warning "attribute declaration must precede definition" for
GC_pthread_exit when this header included from extra/gc.c tail.
Ivan Maidanski [Sun, 9 Sep 2012 07:15:48 +0000 (11:15 +0400)]
Replace var-args GC_noop with fixed-args one
(to suppress Clang warning that arguments were dropped)
* alloc.c (GC_stopped_mark, GC_try_to_collect_general): Use GC_noop6
instead of var-args GC_noop.
* include/private/gc_priv.h (GC_noop): Replace var-args (and
platform-specific) prototype with GC_noop6 one.
* mark.c (GC_noop): Replace with GC_noop6 (with all arguments
ignored); refine comment.
Ivan Maidanski [Sun, 9 Sep 2012 06:42:48 +0000 (10:42 +0400)]
Remove dummy GC_noop call from code visible to Lint tool only
(Minor code refactoring.)
* misc.c (GC_init): Remove dummy GC_noop call from Lint-only code.
* tests/test.c (main): Likewise.
Ivan Maidanski [Sat, 8 Sep 2012 19:54:50 +0000 (23:54 +0400)]
Use GC_noop1 instead of GC_noop in GC_pause; remove duplicate GC_noop1
prototype (minor code refactoring)
* include/private/gc_locks.h (GC_noop1): Remove prototype (since
already declared in gc_priv.h).
* pthread_support.c (GC_pause): Replace varargs GC_noop invocation
(with a single argument) to GC_noop1.
Ivan Maidanski [Wed, 5 Sep 2012 22:16:24 +0000 (02:16 +0400)]
Update ChangeLog and AUTHORS files
Colin LeMahieu [Wed, 5 Sep 2012 22:02:16 +0000 (02:02 +0400)]
Fix GC_get_stack_base assembly code (Cygwin/Clang)
* os_dep.c (GC_get_stack_base): Use inline assembly statement instead
of variable assembly attribute (to workaround clang 3.1 linkage error
on Cygwin).
Ivan Maidanski [Thu, 30 Aug 2012 04:54:09 +0000 (08:54 +0400)]
Update ChangeLog file
Ivan Maidanski [Thu, 30 Aug 2012 04:52:13 +0000 (08:52 +0400)]
Eliminate 'missing exception specification' warning in gc_cpp.cc (Clang)
* gc_cpp.cc (GC_NEW_DELETE_NEED_THROW): Define new macro (if not defined
yet) for GCC v4.2+ (or clang).
* gc_cpp.cc: Include new (for std::bad_alloc) if
GC_NEW_DELETE_NEED_THROW.
* gc_cpp.cc (GC_DECL_NEW_THROW, GC_DECL_DELETE_THROW): New macros
(used to eliminate compiler "missing exception specification" warning
for 'new' and 'delete' operators).
* gc_cpp.cc (new, delete, new[], delete[]): Use
GC_DECL_NEW/DELETE_THROW to define 'throw' clause properly.
Ivan Maidanski [Thu, 30 Aug 2012 04:47:42 +0000 (08:47 +0400)]
.gitignore: Remove old /include/private/config.h.in entry
Ivan Maidanski [Thu, 30 Aug 2012 04:46:37 +0000 (08:46 +0400)]
Update ChangeLog file
Ivan Maidanski [Thu, 30 Aug 2012 04:39:25 +0000 (08:39 +0400)]
.gitignore: remove path prefix for config.h and stamp-h1
* .gitignore: Add include/config.h.in (to ignore); remove path for
config.h and stamp-h1 (to ignore files both located in /include/private
(old behavior) and in /include folders).
Ivan Maidanski [Thu, 30 Aug 2012 04:32:15 +0000 (08:32 +0400)]
Include "config.h" instead of "private/config.h" on HAVE_CONFIG_H
(Change the behavior of HAVE_CONFIG_H macro to the standard one
which assumes that no folder is specified in #include "config.h".)
* configure.ac (AM_CONFIG_HEADER): Replace include/private/config.h to
include/config.h.
* cord/cordbscs.c: Include "config.h" (instead of "private/config.h")
if HAVE_CONFIG_H defined.
* cord/cordprnt.c: Likewise.
* cord/cordxtra.c: Likewise.
* gc_cpp.cc: Likewise.
* include/private/gc_pmark.h: Likewise.
* include/private/gc_priv.h: Likewise.
* real_malloc.c: Likewise.
* tests/disclaim_test.c: Likewise.
* tests/initsecondarythread.c: Likewise.
* tests/subthread_create.c: Likewise.
* tests/test.c: Likewise.
* tests/test_cpp.cc: Likewise.
* tests/thread_leak_test.c: Likewise.
* tests/threadkey_test.c: Likewise.
Ivan Maidanski [Mon, 27 Aug 2012 04:41:13 +0000 (08:41 +0400)]
Update ChangeLog file
Ivan Maidanski [Sun, 26 Aug 2012 19:03:50 +0000 (23:03 +0400)]
Update AUTHORS (add email)
Thomas Klausner [Sun, 26 Aug 2012 18:58:17 +0000 (22:58 +0400)]
Fix unportable '==' test operators in configure
* configure.ac: Replace all unportable '==' test operators with '='
ones.
Petter Urkedal [Tue, 21 Aug 2012 21:08:08 +0000 (23:08 +0200)]
Elaborate comment on dependencies in autogen.sh.
Ivan Maidanski [Tue, 21 Aug 2012 18:20:04 +0000 (22:20 +0400)]
Update ChangeLog file
Ivan Maidanski [Tue, 21 Aug 2012 18:09:50 +0000 (22:09 +0400)]
Add note about 'pkg-config' solving problem with autoconf 2.68 or older
(Cygwin/MinGW, OS X)
* autogen.sh: Add comment about 'pkg-config'.
* TODO: Remove note about 'autoreconf' failure.
Ivan Maidanski [Sun, 5 Aug 2012 09:53:43 +0000 (13:53 +0400)]
Update ChangeLog file
Ivan Maidanski [Wed, 1 Aug 2012 22:02:08 +0000 (02:02 +0400)]
Fix GC_clear_stack_inner by using GC_approx_sp
* misc.c (GC_clear_stack_inner): Use GC_approx_sp() instead of
"dummy[0]" set to "&dummy" value (that worked as expected only for
STACK_GROWS_DOWN case).
Ivan Maidanski [Wed, 1 Aug 2012 19:36:16 +0000 (23:36 +0400)]
Fix all address-of-dummy operations by using GC_approx_sp() instead
(previous commit 'd6acbda' has not solved this problem)
* alloc.c (min_bytes_allocd, GC_stopped_mark): Use GC_approx_sp()
instead of "&dummy"; remove 'dummy' local variable.
* dyn_load.c (GC_cond_add_roots): Likewise.
* misc.c (GC_init): Likewise.
* os_dep.c (GC_get_stack_base, GC_get_main_stack_base): Likewise.
* pthread_stop_world.c (GC_suspend_handler_inner,
nacl_pre_syscall_hook, __nacl_suspend_thread_if_needed): Likewise.
* pthread_support.c (GC_thr_init): Likewise.
* ptr_chck.c (GC_on_stack): Likewise.
* win32_threads.c (GC_push_stack_for): Likewise.
* misc.c (GC_clear_stack_inner): Store address of volatile 'dummy'
local array (i.e. 'sp' value) to its first element (and use it in the
comparison of addresses) to prevent any harmful optimizations as C
officially disallows comparisons of pointers to different objects
(e.g., some Mac OS X clang releases might turn a conditional
expression that uses 'dummy' address into a constant); update comment.
* misc.c (GC_call_with_stack_base): Use "&base" instead of "&dummy"
(it is safe to use address of base here); remove dummy variable.
* os_dep.c (currently_updating): Change type from "word" to "int*".
* os_dep.c (async_set_pht_entry_from_index): Remove volatile and casts
for 'update_dummy' local variable.
* tools/setjmp_t.c (main): Define volatile 'sp' local variable, store
its address to it and use it instead of "&dummy"; remove 'dummy' local
variable.
Ivan Maidanski [Wed, 1 Aug 2012 19:12:22 +0000 (23:12 +0400)]
Fix GC_call_with_stack_base to prevent its tail-call optimization
* misc.c (GC_call_with_stack_base): Call GC_noop1 after fn()
invocation to prevent a tail-call optimization.
Ivan Maidanski [Wed, 1 Aug 2012 05:50:01 +0000 (09:50 +0400)]
Resolve GCC warning in setjmp_t.c
* tools/setjmp_t.c (nested_sp): Change 'sp' local variable type from
int to word (to avoid 'cast from pointer to int' compiler warning).
* tools/setjmp_t.c (main): Cast pointers to unsigned long via word
type; cast WORDSZ value passed to printf() to match format type
specifier (to avoid compiler warnings).
Ivan Maidanski [Wed, 1 Aug 2012 05:42:36 +0000 (09:42 +0400)]
Fix all address-of-dummy operations by adding volatile
* alloc.c (min_bytes_allocd, GC_stopped_mark): Use volatile for
'dummy' local variable (used to get 'sp' value) to prevent any
harmful optimizations (e.g., some Mac OS X clang releases might turn
a conditional expression that uses 'dummy' address into a constant).
* dyn_load.c (GC_cond_add_roots): Likewise.
* mach_dep.c (GC_with_callee_saves_pushed): Likewise.
* misc.c (GC_clear_stack_inner, GC_init, GC_call_with_stack_base):
Likewise.
* os_dep.c (GC_get_stack_base, GC_get_main_stack_base,
async_set_pht_entry_from_index): Likewise.
* pthread_stop_world.c (nacl_pre_syscall_hook,
__nacl_suspend_thread_if_needed): Likewise.
* pthread_support.c (GC_thr_init): Likewise.
* ptr_chck.c (GC_on_stack): Likewise.
* tools/setjmp_t.c (main): Likewise.
* win32_threads.c (GC_push_stack_for): Likewise.
* dyn_load.c (dummy): Change variable type from char to int.
* include/private/gcconfig.h: Update comment about GC_stackbottom
initialization.
* os_dep.c (GC_get_stack_base): Remove 'sp' local variable.
* os_dep.c (GC_get_main_stack_base): Define and use volatile 'dummy'
variable (instead of 'result') to get 'sp' value (revert part of
commit bddc75f).
* os_dep.c (GC_get_stack_base): Add missing cast of 'dummy' address
(only if NEED_FIND_LIMIT).
* pthread_stop_world.c (GC_suspend_handler_inner): Define and use
volatile 'dummy' variable (instead of 'me') to get 'sp' value (revert
part of commit 31fc0f6).
* pthread_stop_world.c (nacl_pre_syscall_hook,
__nacl_suspend_thread_if_needed): Rename 'local_dummy' to 'dummy'
local variable.
Ivan Maidanski [Tue, 24 Jul 2012 10:07:26 +0000 (14:07 +0400)]
TODO file: Add FIXME item about deadlock on Darwin
Ivan Maidanski [Tue, 24 Jul 2012 09:33:08 +0000 (13:33 +0400)]
Update ChangeLog file
Ivan Maidanski [Tue, 24 Jul 2012 09:32:37 +0000 (13:32 +0400)]
Update TODO file (regarding segfault in GC_typed_mark_proc)
Ivan Maidanski [Tue, 24 Jul 2012 09:23:12 +0000 (13:23 +0400)]
Postpone the suspend signal in GC_dirty_init only if used to stop world
* os_dep.c (GC_dirty_init): Do not call sigaddset(SIG_SUSPEND) if
no THREADS or if SIG_SUSPEND is unused for suspending threads.
Ivan Maidanski [Tue, 24 Jul 2012 06:34:15 +0000 (10:34 +0400)]
Fix GC_dirty_init by avoiding GC_get_suspend_signal if no threads support
(fix commit '05daaee')
* os_dep.c (GC_dirty_init): Pass SIG_SUSPEND instead of
GC_get_suspend_signal() to sigaddset() if no THREADS (or if
GC_OPENBSD_THREADS, or GC_WIN32_THREADS or NACL).
* pthread_support.c (pthread_sigmask): Assert GC_get_suspend_signal()
does not return -1 (only if not GC_NO_PTHREAD_SIGMASK).
Ivan Maidanski [Sun, 22 Jul 2012 06:20:57 +0000 (10:20 +0400)]
TODO file: Refine FIXME item about OpenBSD
Ivan Maidanski [Sat, 21 Jul 2012 09:32:50 +0000 (13:32 +0400)]
Update ChangeLog file
Ivan Maidanski [Sat, 21 Jul 2012 08:02:37 +0000 (12:02 +0400)]
TODO file: Update FIXME item about OpenBSD
Ivan Maidanski [Sat, 21 Jul 2012 07:55:56 +0000 (11:55 +0400)]
Dummy merge branch 'fix-logging-atexit-not-working'
(the solution seems to not fix the problem)
Ivan Maidanski [Fri, 20 Jul 2012 20:36:34 +0000 (00:36 +0400)]
Fix stop_info.stack_ptr assignment in GC_suspend_all for OpenBSD
* os_dep.c (GC_get_stack_base): Abort if pthread_stackseg_np fails
(if GC_OPENBSD_THREADS).
* pthread_stop_world.c (GC_suspend_all): Get correct stack_ptr by
calling pthread_stackseg_np (subtracting ss_size from ss_sp) instead
of retrieving it from OpenBSD pthread implementation-dependent context
(if GC_OPENBSD_THREADS); remove test of stack_ptr and comment.
Ivan Maidanski [Fri, 20 Jul 2012 11:27:54 +0000 (15:27 +0400)]
Test SP obtained from OpenBSD-specific pthread context in GC_suspend_all
* pthread_stop_world.c (GC_suspend_all): Abort if stop_info.stack_ptr
obtained from OpenBSD-specific pthread context is NULL; add FIXME for
GC_OPENBSD_THREADS case (the implementation should probably use
pthread_sp_np).
Ivan Maidanski [Fri, 20 Jul 2012 10:23:10 +0000 (14:23 +0400)]
Replace sprintf with defensive snprintf
* dyn_load.c (GC_register_dynamic_libraries): Replace sprintf with
snprintf add put traling '\0' to buffer to prevent buffer overrun;
cast snprintf result to void (to suppress compiler warning).
* cord/tests/cordtest.c (test_printf): Likewise.
* os_dep.c (GC_print_callers): Likewise.
* os_dep.c (GC_dirty_init): Likewise (if PROC_VDB).
* dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove): Put trailing
'\0' to buffer and cast snprintf result to void (Darwin).
Ivan Maidanski [Fri, 20 Jul 2012 09:09:18 +0000 (13:09 +0400)]
Suppress GCC warning in GC_get_main_stack_base (OpenBSD)
* include/private/gcconfig.h (STACKBOTTOM): Cast USRSTACK to ptr_t if
OPENBSD (to suppress GCC warning in GC_get_main_stack_base).
Ivan Maidanski [Fri, 20 Jul 2012 08:59:46 +0000 (12:59 +0400)]
Use memcpy (BCOPY) instead of strcpy (to suppress GCC warning)
* cord/cordbscs.c (CORD_from_fn, CORD_substr_checked): Use memcpy
instead of strcpy (to suppress GCC/ld warning
"strcpy() is almost always misused").
* dbg_mlc.c (GC_debug_strdup): Replace strcpy and memcpy with
cross-platform BCOPY (with reversed order of "src" and "dest"
arguments).
* mallocx.c (GC_strdup): Likewise.
* misc.c (GC_envfile_init, GC_CreateLogFile): Likewise.
* os_dep.c (GC_print_callers): Likewise.
Ivan Maidanski [Fri, 20 Jul 2012 07:22:24 +0000 (11:22 +0400)]
Include pthread_np.h from pthread_stop_world.c on OpenBSD
* pthread_stop_world.c: Include pthread_np.h if GC_OPENBSD_THREADS to
get pthread_suspend_np() and pthread_resume_np() declarations.
Ivan Maidanski [Fri, 20 Jul 2012 07:10:10 +0000 (11:10 +0400)]
Disable find-leak GC_gcollect on GC abnormal EXIT
* misc.c (GC_exit_check): Test GC_find_leak, if it is switched off
then do not invoke GC_gcollect.
* misc.c (GC_default_on_abort): Explicitly turn off GC_find_leak to
prevent redundant garbage collection on EXIT (caused by some GC
failure).
Ivan Maidanski [Thu, 19 Jul 2012 09:48:07 +0000 (13:48 +0400)]
Code refactoring of GC_x_printf (move shared code to macro)
* misc.c (GC_PRINTF_IMPL): New macro (used by GC_[err/log_]printf
only); copy code from GC_err_printf parametrizing output stream.
* misc.c (GC_printf, GC_err_printf, GC_log_printf): Replace shared
code with GC_PRINTF_IMPL macro usage.
Ivan Maidanski [Thu, 19 Jul 2012 09:48:07 +0000 (13:48 +0400)]
Code refactoring of GC_x_printf (move shared code to macro)
* misc.c (GC_PRINTF_IMPL): New macro (used by GC_[err/log_]printf
only); copy code from GC_err_printf parametrizing output stream.
* misc.c (GC_printf, GC_err_printf, GC_log_printf): Replace shared
code with GC_PRINTF_IMPL macro usage.
Ivan Maidanski [Wed, 18 Jul 2012 15:41:43 +0000 (19:41 +0400)]
Fix GC_err_printf called from atexit hook by duping GC_stderr (Unix)
* misc.c: Include unistd.h if UNIX_LIKE (or CYGWIN32 or SYMBIAN) for
dup() prototype.
* misc.c (GC_init): Test "GC_FIND_LEAK" environment variable before
that for "GC_LOG_FILE" (since the block for the latter uses
GC_find_leak value).
* misc.c (GC_init): Invoke dup (only if UNIX_LIKE or CYGWIN32 or
SYMBIAN) for GC_stderr and GC_stdout in case of GC_find_leak but
when GC_stdout/err are not redirected to a file (to workaround
outputting to closed stderr/out file descriptor when GC_gcollect
(GC_print_callers) is called from atexit hook); add comment.
Ivan Maidanski [Wed, 18 Jul 2012 14:06:46 +0000 (18:06 +0400)]
TODO: Add FIXME items for FreeBSD and OpenBSD
Ivan Maidanski [Sat, 14 Jul 2012 08:57:57 +0000 (12:57 +0400)]
Update ChangeLog file
Ivan Maidanski [Sat, 14 Jul 2012 08:51:01 +0000 (12:51 +0400)]
Recognize GC_SIG_SUSPEND and GC_SIG_THR_RESTART tuning macros in gc.h
* include/gc.h (GC_SIG_SUSPEND, GC_SIG_THR_RESTART): New micro
recognized to tune GC_INIT with the non-default signal to be used by
GC to suspend (and resume, respectively) threads (only if GC_THREADS).
* include/gc.h (GC_INIT_CONF_SUSPEND_SIGNAL,
GC_INIT_CONF_THR_RESTART_SIGNAL): New macro (used internally by
GC_INIT).
* include/gc.h (GC_INIT): Invoke GC_INIT_CONF_SUSPEND_SIGNAL and
GC_INIT_CONF_THR_RESTART_SIGNAL before GC_init().
Ivan Maidanski [Sat, 14 Jul 2012 08:11:00 +0000 (12:11 +0400)]
Merge branch 'add-signals-setters'
Ivan Maidanski [Wed, 4 Jul 2012 16:55:02 +0000 (20:55 +0400)]
Dummy merge remote-tracking branch 'jcbeaudoin/signals_init'
Jean-Claude Beaudoin [Wed, 4 Jul 2012 16:53:57 +0000 (20:53 +0400)]
Add thread suspend/resume signals public setters (POSIX threads)
* include/gc.h (GC_set_suspend_signal, GC_set_thr_restart_signal):
Add public function declaration (to specify non-default signals to
suspend/resume threads).
* include/gc.h (GC_get_suspend_signal, GC_get_thr_restart_signal):
Update comment.
* misc.c (GC_set_suspend_signal, GC_set_thr_restart_signal): Add
public no-op function (only for Darwin, OpenBSD, Win32 and NaCl).
* pthread_stop_world.c (GC_set_suspend_signal,
GC_set_thr_restart_signal): Add public setter to alter the default
signals used to suspend and resume threads (only if not OpenBSD or
NaCl); has no effect if GC is initialized.
Ivan Maidanski [Wed, 4 Jul 2012 15:59:34 +0000 (19:59 +0400)]
Move GC_get_suspend/thr_restart_signal to misc.c for NaCl and OpenBSD
* misc.c (GC_get_suspend_signal, GC_get_thr_restart_signal): Define
also for OpenBSD and NaCl targets in this file (always returns -1).
* pthread_stop_world.c (GC_get_suspend_signal,
GC_get_thr_restart_signal): Move function definition up to the
definition of GC_sig_suspend and GC_sig_thr_restart variables (i.e.,
define function only if not OpenBSD and not NaCl target in this file).
Ivan Maidanski [Wed, 4 Jul 2012 15:00:41 +0000 (19:00 +0400)]
Replace SIG_SUSPEND macro to a variable in pthread_stop_world
* misc.c (GC_get_suspend_signal): Define (as always returning -1) in
this file only if Darwin or Win32 threads.
* os_dep.c (GC_dirty_init): Replace SIG_SUSPEND with the value of
GC_get_suspend_signal() invocation.
* pthread_support.c (pthread_sigmask): Likewise.
* pthread_stop_world.c (GC_sig_suspend): New STATIC variable (only
unless NaCl or OpenBSD) initialized to SIG_SUSPEND.
* pthread_stop_world.c (GC_unblock_gc_signals,
GC_suspend_handler_inner, GC_suspend_all, GC_stop_init): Use
GC_sig_suspend instead of SIG_SUSPEND (only unless NaCl or OpenBSD);
update comment.
* pthread_stop_world.c (GC_get_suspend_signal): Define function (which
returns GC_sig_suspend if available).
Ivan Maidanski [Wed, 4 Jul 2012 04:33:33 +0000 (08:33 +0400)]
Replace SIG_THR_RESTART macro to a variable in pthread_stop_world
* pthread_stop_world.c (GC_sig_thr_restart): New STATIC variable
(only unless NaCl or OpenBSD) initialized to SIG_THR_RESTART.
* pthread_stop_world.c (GC_unblock_gc_signals,
GC_suspend_handler_inner, GC_restart_handler, GC_start_world,
GC_stop_init, GC_get_thr_restart_signal): Use GC_sig_thr_restart
instead of SIG_THR_RESTART (only unless NaCl or OpenBSD); update
comment.
Jean-Claude Beaudoin [Tue, 3 Jul 2012 01:38:55 +0000 (21:38 -0400)]
Fixed typo in restart signal setter function name.
Jean-Claude Beaudoin [Tue, 3 Jul 2012 01:36:10 +0000 (21:36 -0400)]
Extend new suspend/restart signal macro redirection to other OSes beyond Linux.
Ivan Maidanski [Sat, 30 Jun 2012 14:35:24 +0000 (18:35 +0400)]
Update ChangeLog file
Ivan Maidanski [Sat, 30 Jun 2012 14:32:13 +0000 (18:32 +0400)]
Merge branch 'add-abort-exit-setters'
Ivan Maidanski [Wed, 27 Jun 2012 19:44:45 +0000 (23:44 +0400)]
Update ChangeLog file
Ivan Maidanski [Tue, 26 Jun 2012 13:29:12 +0000 (17:29 +0400)]
Update ChangeLog file
Ivan Maidanski [Sun, 24 Jun 2012 09:45:33 +0000 (13:45 +0400)]
Dummy merge branch 'jcbeaudoin/exit_abort_hooks'
(superseded by functionality added in commit d020903)
Ivan Maidanski [Sat, 23 Jun 2012 18:42:36 +0000 (22:42 +0400)]
Add public GC_set/get_abort_func to replace default GC_on_abort
* include/gc.h (GC_abort_func): New public typedef.
* include/gc.h (GC_set_abort_func, GC_get_abort_func): New API
function declaration.
* include/private/gc_priv.h (GC_on_abort): Change function
declaration to function pointer of GC_abort_func type (only if
SMALL_CONFIG and not PCR).
* misc.c (GC_on_abort): Rename to GC_default_on_abort; make it STATIC
and decorate with GC_CALLBACK; define GC_on_abort variable initialized
to GC_default_on_abort (only if SMALL_CONFIG and not PCR).
* misc.c (GC_set_abort_func, GC_get_abort_func): New public function
(only if if SMALL_CONFIG and not PCR) to alter and read GC_on_abort
value.
Ivan Maidanski [Sun, 24 Jun 2012 09:04:32 +0000 (13:04 +0400)]
Turn off GC_LOOP_ON_ABORT functionality if GC compiled with NO_DEBUGGING
* misc.c (looping_handler, installed_looping_handler): Do not define
if NO_DEBUGGING.
* misc.c (maybe_install_looping_handler): Define as an empty macro if
NO_DEBUGGING.
* misc.c (GC_on_abort): Do not test "GC_LOOP_ON_ABORT" environment
variable if GC_LOOP_ON_ABORT.
Ivan Maidanski [Sun, 24 Jun 2012 08:49:10 +0000 (12:49 +0400)]
Call GC_on_abort (with NULL argument) on exit(1)
* include/private/gc_priv.h (EXIT): Call GC_on_abort(NULL) before
exit(1) (unless PCR) enabling the collector to enter a tight loop
(for debugging purpose) on abnormal EXIT if "GC_LOOP_ON_ABORT"
environment variable is set.
* misc.c (GC_on_abort): Allow "msg" argument to be NULL (skip
printing the message in such a case); update comment.
Jean-Claude Beaudoin [Sun, 24 Jun 2012 07:28:11 +0000 (03:28 -0400)]
Better handling in signal setter/getter of non-signal-using OSes.
Jean-Claude Beaudoin [Sun, 24 Jun 2012 07:15:46 +0000 (03:15 -0400)]
Segregated suspend/restart signal init changes into their own branch.
Jean-Claude Beaudoin [Sun, 24 Jun 2012 06:32:51 +0000 (02:32 -0400)]
Added documentation to abort and exit callback hook declarations.
Jean-Claude Beaudoin [Sun, 24 Jun 2012 04:08:50 +0000 (00:08 -0400)]
Added getters for exit and abort callback hooks.
Jean-Claude Beaudoin [Sun, 24 Jun 2012 03:34:50 +0000 (23:34 -0400)]
Segregated exit and abort hooks changes into their own branch
Ivan Maidanski [Sat, 23 Jun 2012 19:37:30 +0000 (23:37 +0400)]
Replace exit(1) with EXIT call in catch_exception_raise (code refactoring)
* os_dep.c (catch_exception_raise): Replace exit(EXIT_FAILURE) call
with EXIT() macro call.
Jean-Claude Beaudoin [Fri, 22 Jun 2012 04:53:57 +0000 (00:53 -0400)]
Added GC_CALLBACK to abort() and exit() callback hooks typedefs.
Jean-Claude Beaudoin [Fri, 22 Jun 2012 04:40:04 +0000 (00:40 -0400)]
Fixed STATIC style for exit() and abort() callback hooks.
Jean-Claude Beaudoin [Fri, 22 Jun 2012 03:16:32 +0000 (23:16 -0400)]
Added abort() and exit() callback hooks.
Added SIG_SUSPEND and SIG_THR_RESTART configuration at GC_init() time.
Ivan Maidanski [Sun, 17 Jun 2012 16:25:09 +0000 (20:25 +0400)]
Fix thread-related tests for pthreads-w32
* tests/initsecondarythread.c: Include "private/config.h" if
HAVE_CONFIG_H (mostly to have GC_WIN32_PTHREADS defined for
pthreads-w32 target).
* tests/thread_leak_test.c: Likewise.
* tests/threadkey_test.c: Likewise.
Ivan Maidanski [Sat, 16 Jun 2012 09:35:53 +0000 (13:35 +0400)]
tools: Include proper header file for configuration macros
* tools/if_mach.c: Include private/gc_priv.h instead of
private/gcconfig.h (to get proper configuration macros defined).
* tools/if_not_there.c: Likewise.
* tools/threadlibs.c: Likewise.
* tools/threadlibs.c: Do not include gc_config_macros.h directly.
Ivan Maidanski [Sat, 16 Jun 2012 08:54:36 +0000 (12:54 +0400)]
test_cpp: Fix WinMain to prevent SEGV if zero arguments passed (MinGW)
* tests/test_cpp.cc (WinMain): Prevent SEGV in strtok() by checking
"cmd" WinMain argument for NULL (in that case "argc" local variable is
set to 0).