README.linux 4.4 KB

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