README.linux 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. See README.alpha for Linux on DEC AXP info.
  2. This file applies mostly to Linux/Intel IA-32. Ports to Linux on an M68K,
  3. IA-64, SPARC, MIPS, Alpha and PowerPC are integrated too. They should behave
  4. similarly, except that the PowerPC port lacks incremental GC support, and
  5. it is unknown to what extent the Linux threads code is functional.
  6. See below for M68K specific notes.
  7. Incremental GC is generally supported.
  8. Dynamic libraries are supported on an ELF system.
  9. The collector appears to work reliably with Linux threads, but beware
  10. of older versions of glibc and gdb.
  11. The garbage collector uses SIGPWR and SIGXCPU if it is used with
  12. Linux threads. These should not be touched by the client program.
  13. To use threads, you need to abide by the following requirements:
  14. 1) You need to use LinuxThreads or NPTL (which are included in libc6).
  15. The collector relies on some implementation details of the LinuxThreads
  16. package. This code may not work on other
  17. pthread implementations (in particular it will *not* work with
  18. MIT pthreads).
  19. 2) You must compile the collector with "-DGC_THREADS -D_REENTRANT" specified
  20. in the Makefile.direct file.
  21. 3a) Every file that makes thread calls should define GC_THREADS, and then
  22. include gc.h. The latter redefines some of the pthread primitives as
  23. macros which also provide the collector with information it requires.
  24. 3b) A new alternative to (3a) is to build the collector and compile GC clients
  25. with -DGC_USE_LD_WRAP, and to link the final program with
  26. (for ld) --wrap dlopen --wrap pthread_create \
  27. --wrap pthread_join --wrap pthread_detach \
  28. --wrap pthread_sigmask --wrap pthread_exit --wrap pthread_cancel
  29. (for gcc) -Wl,--wrap -Wl,dlopen -Wl,--wrap -Wl,pthread_create \
  30. -Wl,--wrap -Wl,pthread_join -Wl,--wrap -Wl,pthread_detach \
  31. -Wl,--wrap -Wl,pthread_sigmask -Wl,--wrap -Wl,pthread_exit \
  32. -Wl,--wrap -Wl,pthread_cancel
  33. In any case, _REENTRANT should be defined during compilation.
  34. 4) Dlopen() disables collection during its execution. (It can't run
  35. concurrently with the collector, since the collector looks at its
  36. data structures. It can't acquire the allocator lock, since arbitrary
  37. user startup code may run as part of dlopen().) Under unusual
  38. conditions, this may cause unexpected heap growth.
  39. 5) The combination of GC_THREADS, REDIRECT_MALLOC, and incremental
  40. collection is probably not fully reliable, though it now seems to work
  41. in simple cases.
  42. 6) Thread local storage may not be viewed as part of the root set by the
  43. collector. This probably depends on the linuxthreads version. For the
  44. time being, any collectible memory referenced by thread local storage
  45. should also be referenced from elsewhere, or be allocated as uncollectible.
  46. (This is really a bug that should be fixed somehow. Actually, the
  47. collector probably gets things right, on Linux at least, if there are not
  48. too many tls locations and if dlopen is not used.)
  49. M68K LINUX:
  50. (From Richard Zidlicky)
  51. The bad news is that it can crash every linux-m68k kernel on a 68040,
  52. so an additional test is needed somewhere on startup. I have meanwhile
  53. patches to correct the problem in 68040 buserror handler but it is not
  54. yet in any standard kernel.
  55. Here is a simple test program to detect whether the kernel has the
  56. problem. It could be run as a separate check in configure or tested
  57. upon startup. If it fails (return !0) than mprotect can't be used
  58. on that system.
  59. /*
  60. * test for bug that may crash 68040 based Linux
  61. */
  62. #include <sys/mman.h>
  63. #include <signal.h>
  64. #include <unistd.h>
  65. #include <stdio.h>
  66. #include <stdlib.h>
  67. char *membase;
  68. int pagesize=4096;
  69. int pageshift=12;
  70. int x_taken=0;
  71. int sighandler(int sig)
  72. {
  73. mprotect(membase,pagesize,PROT_READ|PROT_WRITE);
  74. x_taken=1;
  75. }
  76. main()
  77. {
  78. long l;
  79. signal(SIGSEGV,sighandler);
  80. l=(long)mmap(NULL,pagesize,PROT_READ,MAP_PRIVATE | MAP_ANON,-1,0);
  81. if (l==-1)
  82. {
  83. perror("mmap/malloc");
  84. abort();
  85. }
  86. membase=(char*)l;
  87. *(long*)(membase+sizeof(long))=123456789;
  88. if (*(long*)(membase+sizeof(long)) != 123456789 )
  89. {
  90. fprintf(stderr,"writeback failed !\n");
  91. exit(1);
  92. }
  93. if (!x_taken)
  94. {
  95. fprintf(stderr,"exception not taken !\n");
  96. exit(1);
  97. }
  98. fprintf(stderr,"vmtest Ok\n");
  99. exit(0);
  100. }