Fossil SCM
Do not set the RLIMIT_DATA limit in fossil_limit_memory() when built with AddressSanitizer. On Linux the limit made every command of a sanitizer build stop at startup with an out of memory report.
Commit
d2e8a7f16814b5e975d68b494e7578dcf8c4955ccb554b9bd8c820291332c641
Parent
e170dd83e5d053e…
1 file changed
+16
-2
+16
-2
| --- src/util.c | ||
| +++ src/util.c | ||
| @@ -769,24 +769,38 @@ | ||
| 769 | 769 | if( zTempDirA ) fossil_path_free(zTempDirA); |
| 770 | 770 | #endif |
| 771 | 771 | return zTFile; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | +/* | |
| 775 | +** FOSSIL_ASAN is defined if this is a build with AddressSanitizer, which | |
| 776 | +** needs more address space for its own use than the heap limit allows. | |
| 777 | +*/ | |
| 778 | +#if defined(__SANITIZE_ADDRESS__) | |
| 779 | +# define FOSSIL_ASAN 1 | |
| 780 | +#elif defined(__has_feature) | |
| 781 | +# if __has_feature(address_sanitizer) | |
| 782 | +# define FOSSIL_ASAN 1 | |
| 783 | +# endif | |
| 784 | +#endif | |
| 785 | + | |
| 774 | 786 | /* |
| 775 | 787 | ** Turn memory limits for stack and heap on and off. The argument |
| 776 | 788 | ** is true to turn memory limits on and false to turn them off. |
| 777 | 789 | ** |
| 778 | 790 | ** Memory limits should be enabled at startup, but then turned off |
| 779 | 791 | ** before starting subprocesses. |
| 780 | 792 | */ |
| 781 | 793 | void fossil_limit_memory(int onOff){ |
| 782 | 794 | #if defined(__unix__) |
| 795 | +#if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) | |
| 783 | 796 | static sqlite3_int64 origHeap = 10000000000LL; /* 10GB */ |
| 797 | +#endif | |
| 784 | 798 | static sqlite3_int64 origStack = 8000000 ; /* 8MB */ |
| 785 | 799 | struct rlimit x; |
| 786 | 800 | |
| 787 | -#if defined(RLIMIT_DATA) | |
| 801 | +#if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) | |
| 788 | 802 | getrlimit(RLIMIT_DATA, &x); |
| 789 | 803 | if( onOff ){ |
| 790 | 804 | origHeap = x.rlim_cur; |
| 791 | 805 | if( sizeof(void*)<8 || sizeof(x.rlim_cur)<8 ){ |
| 792 | 806 | x.rlim_cur = 1000000000 ; /* 1GB on 32-bit systems */ |
| @@ -795,11 +809,11 @@ | ||
| 795 | 809 | } |
| 796 | 810 | }else{ |
| 797 | 811 | x.rlim_cur = origHeap; |
| 798 | 812 | } |
| 799 | 813 | setrlimit(RLIMIT_DATA, &x); |
| 800 | -#endif /* defined(RLIMIT_DATA) */ | |
| 814 | +#endif /* defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) */ | |
| 801 | 815 | #if defined(RLIMIT_STACK) |
| 802 | 816 | getrlimit(RLIMIT_STACK, &x); |
| 803 | 817 | if( onOff ){ |
| 804 | 818 | origStack = x.rlim_cur; |
| 805 | 819 | x.rlim_cur = 8000000; /* 8MB */ |
| 806 | 820 |
| --- src/util.c | |
| +++ src/util.c | |
| @@ -769,24 +769,38 @@ | |
| 769 | if( zTempDirA ) fossil_path_free(zTempDirA); |
| 770 | #endif |
| 771 | return zTFile; |
| 772 | } |
| 773 | |
| 774 | /* |
| 775 | ** Turn memory limits for stack and heap on and off. The argument |
| 776 | ** is true to turn memory limits on and false to turn them off. |
| 777 | ** |
| 778 | ** Memory limits should be enabled at startup, but then turned off |
| 779 | ** before starting subprocesses. |
| 780 | */ |
| 781 | void fossil_limit_memory(int onOff){ |
| 782 | #if defined(__unix__) |
| 783 | static sqlite3_int64 origHeap = 10000000000LL; /* 10GB */ |
| 784 | static sqlite3_int64 origStack = 8000000 ; /* 8MB */ |
| 785 | struct rlimit x; |
| 786 | |
| 787 | #if defined(RLIMIT_DATA) |
| 788 | getrlimit(RLIMIT_DATA, &x); |
| 789 | if( onOff ){ |
| 790 | origHeap = x.rlim_cur; |
| 791 | if( sizeof(void*)<8 || sizeof(x.rlim_cur)<8 ){ |
| 792 | x.rlim_cur = 1000000000 ; /* 1GB on 32-bit systems */ |
| @@ -795,11 +809,11 @@ | |
| 795 | } |
| 796 | }else{ |
| 797 | x.rlim_cur = origHeap; |
| 798 | } |
| 799 | setrlimit(RLIMIT_DATA, &x); |
| 800 | #endif /* defined(RLIMIT_DATA) */ |
| 801 | #if defined(RLIMIT_STACK) |
| 802 | getrlimit(RLIMIT_STACK, &x); |
| 803 | if( onOff ){ |
| 804 | origStack = x.rlim_cur; |
| 805 | x.rlim_cur = 8000000; /* 8MB */ |
| 806 |
| --- src/util.c | |
| +++ src/util.c | |
| @@ -769,24 +769,38 @@ | |
| 769 | if( zTempDirA ) fossil_path_free(zTempDirA); |
| 770 | #endif |
| 771 | return zTFile; |
| 772 | } |
| 773 | |
| 774 | /* |
| 775 | ** FOSSIL_ASAN is defined if this is a build with AddressSanitizer, which |
| 776 | ** needs more address space for its own use than the heap limit allows. |
| 777 | */ |
| 778 | #if defined(__SANITIZE_ADDRESS__) |
| 779 | # define FOSSIL_ASAN 1 |
| 780 | #elif defined(__has_feature) |
| 781 | # if __has_feature(address_sanitizer) |
| 782 | # define FOSSIL_ASAN 1 |
| 783 | # endif |
| 784 | #endif |
| 785 | |
| 786 | /* |
| 787 | ** Turn memory limits for stack and heap on and off. The argument |
| 788 | ** is true to turn memory limits on and false to turn them off. |
| 789 | ** |
| 790 | ** Memory limits should be enabled at startup, but then turned off |
| 791 | ** before starting subprocesses. |
| 792 | */ |
| 793 | void fossil_limit_memory(int onOff){ |
| 794 | #if defined(__unix__) |
| 795 | #if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) |
| 796 | static sqlite3_int64 origHeap = 10000000000LL; /* 10GB */ |
| 797 | #endif |
| 798 | static sqlite3_int64 origStack = 8000000 ; /* 8MB */ |
| 799 | struct rlimit x; |
| 800 | |
| 801 | #if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) |
| 802 | getrlimit(RLIMIT_DATA, &x); |
| 803 | if( onOff ){ |
| 804 | origHeap = x.rlim_cur; |
| 805 | if( sizeof(void*)<8 || sizeof(x.rlim_cur)<8 ){ |
| 806 | x.rlim_cur = 1000000000 ; /* 1GB on 32-bit systems */ |
| @@ -795,11 +809,11 @@ | |
| 809 | } |
| 810 | }else{ |
| 811 | x.rlim_cur = origHeap; |
| 812 | } |
| 813 | setrlimit(RLIMIT_DATA, &x); |
| 814 | #endif /* defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) */ |
| 815 | #if defined(RLIMIT_STACK) |
| 816 | getrlimit(RLIMIT_STACK, &x); |
| 817 | if( onOff ){ |
| 818 | origStack = x.rlim_cur; |
| 819 | x.rlim_cur = 8000000; /* 8MB */ |
| 820 |