Skip to content
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

[JENKINS-40470] Jobs didn't finish on Solaris 11 Intel node #2701

Merged
merged 2 commits into from Jan 7, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions core/src/main/java/hudson/util/ProcessTree.java
Expand Up @@ -787,6 +787,13 @@ private class SolarisProcess extends UnixProcess {
private static final byte PR_MODEL_ILP32 = 1;
private static final byte PR_MODEL_LP64 = 2;

/*
* An arbitrary upper-limit on how many characters readLine() will
* try reading before giving up. This avoids having readLine() loop
* over the entire process address space if this class has bugs.
*/
private static final int LINE_LENGTH_LIMIT = 10000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good practice is to make it a SystemProperty in order to allow managing it from the code. Maybe not required here since the limit is big enough for realistic use-cases


/*
* True if target process is 64-bit (Java process may be different).
*/
Expand Down Expand Up @@ -900,7 +907,7 @@ public synchronized List<String> getArguments() {
for( int n=0; n<argc; n++ ) {
// read a pointer to one entry
LIBC.pread(fd, m, new NativeLong(psize), new NativeLong(argp+n*psize));
long addr = b64 ? m.getLong(0) : m.getInt(0);
long addr = b64 ? m.getLong(0) : to64(m.getInt(0));

arguments.add(readLine(fd, addr, "argv["+ n +"]"));
}
Expand Down Expand Up @@ -935,7 +942,7 @@ public synchronized EnvVars getEnvironmentVariables() {
for( int n=0; ; n++ ) {
// read a pointer to one entry
LIBC.pread(fd, m, new NativeLong(psize), new NativeLong(envp+n*psize));
long addr = b64 ? m.getLong(0) : m.getInt(0);
long addr = b64 ? m.getLong(0) : to64(m.getInt(0));
if (addr == 0) // completed the walk
break;

Expand All @@ -959,7 +966,13 @@ private String readLine(int fd, long addr, String prefix) throws IOException {
Memory m = new Memory(1);
byte ch = 1;
ByteArrayOutputStream buf = new ByteArrayOutputStream();
int i = 0;
while(true) {
if (i++ > LINE_LENGTH_LIMIT) {
LOGGER.finest("could not find end of line, giving up");
throw new IOException("could not find end of line, giving up");
}

LIBC.pread(fd, m, new NativeLong(1), new NativeLong(addr));
ch = m.getByte(0);
if (ch == 0)
Expand Down