-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix Solaris 10 build: missing libproc.h #15525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2c44b2b
d11a2b1
1f8713b
c3174d3
3d7d846
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,9 @@ typedef int boolean_t; | |
#define _STRUCTURED_PROC 1 | ||
#include <sys/lwp.h> | ||
#include <sys/procfs.h> | ||
#include <libproc.h> | ||
# ifdef HAVE_LIBPROC_H | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I think the related api usage needs to be guarded, well more likely the full function in fact (by line 704). In other words, if no libproc then the function returns false. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to add a patch for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for my lack of clarity, what I meant is something like this static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack)
{
#ifdef HAVE_LIBPROC_H
char buffer[4096];
uintptr_t addr_on_stack = (uintptr_t) zend_call_stack_position();
bool found = false, r = false;
struct ps_prochandle *proc;
prmap_t *map, *orig;
struct rlimit rlim;
char path[PATH_MAX];
size_t size;
ssize_t len = -1;
pid_t pid;
int error, fd;
pid = getpid();
proc = Pgrab(pid, PGRAB_RDONLY, &error);
if (!proc) {
return false;
}
size = (1 << 20);
snprintf(path, sizeof(path), "/proc/%d/map", (int)pid);
if ((fd = open(path, O_RDONLY)) == -1) {
Prelease(proc, 0);
return false;
}
orig = malloc(size);
if (!orig) {
Prelease(proc, 0);
close(fd);
return false;
}
while (size > 0 && (len = pread(fd, orig, size, 0)) == size) {
prmap_t *tmp;
size <<= 1;
tmp = realloc(orig, size);
if (!tmp) {
goto end;
}
orig = tmp;
}
for (map = orig; len > 0; ++map) {
if ((uintptr_t)map->pr_vaddr <= addr_on_stack && (uintptr_t)map->pr_vaddr + map->pr_size >= addr_on_stack) {
found = true;
break;
}
len -= sizeof(*map);
}
if (!found) {
goto end;
}
error = getrlimit(RLIMIT_STACK, &rlim);
if (error || rlim.rlim_cur == RLIM_INFINITY) {
goto end;
}
stack->base = (void *)map->pr_vaddr + map->pr_size;
stack->max_size = rlim.rlim_cur;
r = true;
end:
free(orig);
Prelease(proc, 0);
close(fd);
return r;
#else
return false;
#endif
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect thanks. :D Appended in the next commit. This looks fine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems, let me know if it builds, I no longer have any solaris stuff needs to recreate my VMs :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, yes, I know. Setting Solaris 10 development environment is not trivial at all. There is even a bug in GCC 5 so the GCC 4.9 needs to be used. And the main issue is getting the re2c newer than 1.0.3 and other dependencies (libxml ...). It builds successfully with this patch in the current PR. |
||
# include <libproc.h> | ||
# endif | ||
#include <thread.h> | ||
#endif | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: if we want to be "nitpicky", sys/procfs.h is also not used then in case the libproc api is not used. Can be guarded as well alongside with the
#define _STRUCTURED_PROC 1
(which is for the sys/procfs.h to enable the newer procfs api). But again, it s being pedantic here :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in the next commit. Builds successfully.