Repository navigation
Fix core file not generating on OSX - #6190
Conversation
|
|
||
| return kr; | ||
| /* check the core file has actually been created */ | ||
| return access(filename, F_OK); |
There was a problem hiding this comment.
We don't want to ignore the value of kr here, and the return type of access() is incompatible with the return type of this function (actually, so is kern_return_t); suggest:
return ((KERN_SUCCESS == kr) && (0 == access(filename, F_OK))) ? 0 : 1;
Other return statements above should either set kr appropriately and goto here, or properly map kern_return_t to uintptr_t.
There was a problem hiding this comment.
Changed it to what you suggested. For the child process though, an error will just cause it to not write the core file and thus fail the access() check at the end, since the value of kr is harder to propagate to the parent.
e7d027c to
af7777a
Compare
keithc-ca
left a comment
There was a problem hiding this comment.
Also, a failure near line 86 will inappropriately return KERN_SUCCESS.
Either initialize kr = KERN_FAILURE or assign it in the if body.
| if (0 != chdir(filename)) { | ||
| perror("failed to change directories for dump"); | ||
| return KERN_FAILURE; | ||
| goto done_child_proc; |
There was a problem hiding this comment.
I think it's better to just ignore this failure and attempt to write the dump in the current directory.
There was a problem hiding this comment.
Changed it as you suggested, if chdir fails it will attempt to create a core dump in the current working directory.
| if (KERN_SUCCESS != kr) { | ||
| mach_error("failed get special port:\n", kr); | ||
| return kr; | ||
| goto done_child_proc; |
There was a problem hiding this comment.
I suggest an else block is preferable to the use of goto here.
af7777a to
a7d4846
Compare
| if (KERN_SUCCESS == kr) { | ||
| return ((0 == access(filename, F_OK)) || (0 == access(corefile_name, F_OK))) ? 0 : 1; | ||
| } else { | ||
| return 1; | ||
| } |
There was a problem hiding this comment.
I think the logic here needs to change. I don't think filename is allowed to be NULL, so the test on line 416 should change.
If filename is empty, the generated name should be written to that buffer.
So this should be something like:
if (KERN_SUCCESS == kr) {
/* check that the core file has been created */
if (0 == access(filename, F_OK)) {
return 0;
}
/* check for the core file in the current directory */
if ((NULL != lastSep) && (0 == access(lastSep + 1, F_OK))) {
return 0;
}
}
return 1;
There was a problem hiding this comment.
For the second check here, why does (NULL != lastSep) need to be true?
There was a problem hiding this comment.
If the caller specified a (possibly empty) file name without a slash, then lastSep would be NULL in which case lastSep + 1 would not be a reasonable address to pass to access().
There was a problem hiding this comment.
Changed so that omrdump_create fails if filename is NULL. It wasn't immediately obvious to me looking at the Unix version, but it occurs in L208 there.
I restructured the access checks as you suggested but kept (0 == access(corefile_name, F_OK)) for the 2nd check in the current working directory, since we already have the file name without any directories stored there.
a7d4846 to
ca65fb3
Compare
| strncpy(corefile_name, filename, PATH_MAX); | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Please remove this extra blank line.
| return 0; | ||
| } | ||
| /* check for corefile in current working directory */ | ||
| if (0 == access(corefile_name, F_OK)) { |
There was a problem hiding this comment.
If NULL == lastSep, this is a repeat of the call to access() above (and just a waste of time).
There was a problem hiding this comment.
You're right, added the check.
When reading memory segments, reset the return value kr so that the generated file is not deleted at the end if the last memory segment throws an error when being read, since mach_vm_read errors are not fatal. Also make sure final return value is correct when there is an error. Signed-off-by: Mike Zhang <mike.h.zhang@ibm.com>
ca65fb3 to
5891fb4
Compare
|
Jenkins build osx |
The return value kr is set to an error value that is non-fatal and should be
reset so that the generated file is not deleted at the end if the last memory
segment throws an error when being read.
Also make sure final return value is correct when there is an error.
Signed-off-by: Mike Zhang mike.h.zhang@ibm.com
Fixes the test issues on 10.11 Macs in eclipse-openj9/openj9#13509
fyi: @pshipton @keithc-ca