]> gcc.gnu.org Git - gcc.git/blame - boehm-gc/README.solaris2
Merged GC 5.0alpha4 with local changes, plus:
[gcc.git] / boehm-gc / README.solaris2
CommitLineData
73ffefd0
TT
1The collector supports both incremental collection and threads under
2Solaris 2. The incremental collector normally retrieves page dirty information
3through the appropriate /proc calls. But it can also be configured
20bbd3cd 4(by defining MPROTECT_VDB instead of PROC_VDB in gcconfig.h) to use mprotect
73ffefd0
TT
5and signals. This may result in shorter pause times, but it is no longer
6safe to issue arbitrary system calls that write to the heap.
7
8Under other UNIX versions,
9the collector normally obtains memory through sbrk. There is some reason
10to expect that this is not safe if the client program also calls the system
11malloc, or especially realloc. The sbrk man page strongly suggests this is
12not safe: "Many library routines use malloc() internally, so use brk()
13and sbrk() only when you know that malloc() definitely will not be used by
14any library routine." This doesn't make a lot of sense to me, since there
15seems to be no documentation as to which routines can transitively call malloc.
16Nonetheless, under Solaris2, the collector now (since 4.12) allocates
20bbd3cd 17memory using mmap by default. (It defines USE_MMAP in gcconfig.h.)
73ffefd0
TT
18You may want to reverse this decisions if you use -DREDIRECT_MALLOC=...
19
20
21SOLARIS THREADS:
22
23The collector must be compiled with -DSOLARIS_THREADS to be thread safe.
24It is also essential that gc.h be included in files that call thr_create,
25thr_join, thr_suspend, thr_continue, or dlopen. Gc.h macro defines
26these to also do GC bookkeeping, etc. Gc.h must be included with
27SOLARIS_THREADS defined, otherwise these replacements are not visible.
28A collector built in this way way only be used by programs that are
29linked with the threads library.
30
31If you are using the Pthreads interface, also define _SOLARIS_PTHREADS.
32
33In this mode, the collector contains various workarounds for older Solaris
34bugs. Mostly, these should not be noticeable unless you look at system
35call traces. However, it cannot protect a guard page at the end of
36a thread stack. If you know that you will only be running Solaris2.5
37or later, it should be possible to fix this by compiling the collector
38with -DSOLARIS23_MPROTECT_BUG_FIXED.
39
40Jeremy Fitzhardinge points out that there is a problem with the dlopen
41replacement, in that startup code in the library is run while the allocation
42lock is held. This appears to be difficult to fix, since the collector does
43look at data structures maintained by dlopen, and hence some locking is needed
44around the dlopen call. Defining USE_PROC_FOR_LIBRARIES will get address
45space layout information from /proc avoiding the dlopen lock. But this has
46other disadvanatages, e.g. mmapped files may be scanned.
47
48If solaris_threads are used on an X86 processor with malloc redirected to
49GC_malloc, it is necessary to call GC_thr_init explicitly before forking the
50first thread. (This avoids a deadlock arising from calling GC_thr_init
51with the allocation lock held.)
52
53It appears that there is a problem in using gc_cpp.h in conjunction with
54Solaris threads and Sun's C++ runtime. Apparently the overloaded new operator
55is invoked by some iostream initialization code before threads are correctly
56initialized. As a result, call to thr_self() in garbage collector
57initialization segfaults. Currently the only known workaround is to not
58invoke the garbage collector from a user defined global operator new, or to
59have it invoke the garbage-collector's allocators only after main has started.
60(Note that the latter requires a moderately expensive test in operator
61delete.)
62
63Hans-J. Boehm
64(The above contains my personal opinions, which are probably not shared
65by anyone else.)
This page took 0.061306 seconds and 5 git commands to generate.