| 138 | |
| 139 | JEMALLOC_ATTR(constructor) |
| 140 | static void WINAPI |
| 141 | _init_init_lock(void) { |
| 142 | /* |
| 143 | * If another constructor in the same binary is using mallctl to e.g. |
| 144 | * set up extent hooks, it may end up running before this one, and |
| 145 | * malloc_init_hard will crash trying to lock the uninitialized lock. So |
| 146 | * we force an initialization of the lock in malloc_init_hard as well. |
| 147 | * We don't try to care about atomicity of the accessed to the |
| 148 | * init_lock_initialized boolean, since it really only matters early in |
| 149 | * the process creation, before any separate thread normally starts |
| 150 | * doing anything. |
| 151 | */ |
| 152 | if (!init_lock_initialized) { |
| 153 | malloc_mutex_init(&init_lock, "init", WITNESS_RANK_INIT, |
| 154 | malloc_mutex_rank_exclusive); |
| 155 | } |
| 156 | init_lock_initialized = true; |
| 157 | } |
| 158 | |
| 159 | #ifdef _MSC_VER |
| 160 | # pragma section(".CRT$XCU", read) |
no test coverage detected