Skip to content

Commit dea55ee

Browse files
Zentrikvchuravy
authored andcommitted
Get analyzegc pass passing
The change to `GCChecker.cpp` is so the static analyzer doesn't see e.g. a call to a function pointer in llvm and then complain that it might be a safepoint.
1 parent c7ecaa0 commit dea55ee

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/cgmemmgr.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,17 @@ static intptr_t get_anon_hdl(void) JL_NOTSAFEPOINT
182182
pid_t pid = getpid();
183183
// `shm_open` can't be mapped exec on mac
184184
# ifndef _OS_DARWIN_
185+
int shm_open_errno;
185186
do {
186187
snprintf(shm_name, sizeof(shm_name),
187188
"julia-codegen-%d-%d", (int)pid, rand());
188189
fd = shm_open(shm_name, O_RDWR | O_CREAT | O_EXCL, S_IRWXU);
190+
shm_open_errno = errno; // check_fd_or_close trashes errno, so save beforehand
189191
if (check_fd_or_close(fd)) {
190192
shm_unlink(shm_name);
191193
return fd;
192194
}
193-
} while (errno == EEXIST);
195+
} while (shm_open_errno == EEXIST);
194196
# endif
195197
FILE *tmpf = tmpfile();
196198
if (tmpf) {

src/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ static void *init_stdio_handle(const char *stdio, uv_os_fd_t fd, int readable)
444444
// This also helps limit the impact other libraries can cause on our file handle.
445445
if ((err = uv_dup(fd, &fd)))
446446
jl_errorf("error initializing %s in uv_dup: %s (%s %d)", stdio, uv_strerror(err), uv_err_name(err), err);
447+
assert(fd != -1); // This avoids a bug in clang's static analyzer, if an error did not occur, fd != -1
447448
switch(uv_guess_handle(fd)) {
448449
case UV_TTY:
449450
handle = malloc_s(sizeof(uv_tty_t));

src/jitlayers.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,15 +2158,19 @@ void JuliaOJIT::addModule(orc::ThreadSafeModule TSM)
21582158
// even though that shouldn't be the case and might be unwise
21592159
Expected<std::unique_ptr<MemoryBuffer>> Obj = CompileLayer.getCompiler()(M);
21602160
if (!Obj) {
2161+
#ifndef __clang_analyzer__ // reportError calls an arbitrary function, which the analyzer thinks might be a safepoint
21612162
ES.reportError(Obj.takeError());
2163+
#endif
21622164
errs() << "Failed to add module to JIT!\n";
21632165
errs() << "Dumping failing module\n" << M << "\n";
21642166
return;
21652167
}
21662168
{ auto release = std::move(Lock); }
21672169
auto Err = JuliaOJIT::addObjectFile(JD, std::move(*Obj));
21682170
if (Err) {
2171+
#ifndef __clang_analyzer__ // reportError calls an arbitrary function, which the analyzer thinks might be a safepoint
21692172
ES.reportError(std::move(Err));
2173+
#endif
21702174
errs() << "Failed to add objectfile to JIT!\n";
21712175
abort();
21722176
}

0 commit comments

Comments
 (0)