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

OSX RasDump Support #3380

Closed
babsingh opened this issue Oct 19, 2018 · 3 comments · Fixed by #3381
Closed

OSX RasDump Support #3380

babsingh opened this issue Oct 19, 2018 · 3 comments · Fixed by #3381

Comments

@babsingh
Copy link
Contributor

While building OpenJ9 JDK8, the following warning was seen:

dmpagent.c:766:8: warning: variable 'async' set but not used [-Wunused-but-set-variable]

For the time being, the above warning doesn't impact the OpenJ9 JDK8 build process since the feature to treat warnings as errors can be disabled. The above warning should be resolved since the end-goal is to treat warnings as errors when building OpenJ9.

The above warning showed that defined(OSX) is unused in the rasdump directory.

Exploring defined(LINUX) locations where defined(OSX) may need to be enabled:

  1. This code is executed from doSystemDump. It seems relevant to OSX. I think it should be enabled.
openj9/runtime/rasdump/dmpagent.c:#if defined(J9VM_OPT_SHARED_CLASSES) && defined(LINUX)
openj9/runtime/rasdump/dmpagent.c-      J9SharedClassJavacoreDataDescriptor sharedClassData;
openj9/runtime/rasdump/dmpagent.c-
openj9/runtime/rasdump/dmpagent.c-      /* set up cacheDir with the Shared Classes Cache file if it is in use. */
openj9/runtime/rasdump/dmpagent.c-      if ((NULL != vm->sharedClassConfig) && (NULL != vm->sharedClassConfig->getJavacoreData)) {
openj9/runtime/rasdump/dmpagent.c-              if (1 == vm->sharedClassConfig->getJavacoreData(vm, &sharedClassData)) {
openj9/runtime/rasdump/dmpagent.c-                      /* test for memory mapped file */
openj9/runtime/rasdump/dmpagent.c-                      if (sharedClassData.shmid == -2) {
openj9/runtime/rasdump/dmpagent.c-                              cacheDir = sharedClassData.cacheDir;
openj9/runtime/rasdump/dmpagent.c-                      }
openj9/runtime/rasdump/dmpagent.c-              }
openj9/runtime/rasdump/dmpagent.c-      }
openj9/runtime/rasdump/dmpagent.c-#endif
  1. Seems specific to RHEL5. Not needed for OSX.
/* _GNU_SOURCE forces GLIBC_2.0 sscanf/vsscanf/fscanf for RHEL5 compatability */
openj9/runtime/rasdump/trigger.c:#if defined(LINUX) && !defined(J9ZTPF)
openj9/runtime/rasdump/trigger.c-#define _GNU_SOURCE
openj9/runtime/rasdump/trigger.c-#endif /* defined(__GNUC__) */
  1. Irrelevant to OSX. /proc/sys/kernel/sched_compat_yield, /proc/sys/kernel/core_pattern and /proc/sys/kernel/core_uses_pid don't exist on OSX.
openj9/runtime/rasdump/dmpsup.c:#if defined(LINUX)
openj9/runtime/rasdump/dmpsup.c-        /* On Linux, store the startup value of /proc/sys/kernel/sched_compat_yield if it's set */
openj9/runtime/rasdump/dmpsup.c-        {
openj9/runtime/rasdump/dmpsup.c-                char schedCompatYieldValue = j9util_sched_compat_yield_value(vm);
openj9/runtime/rasdump/dmpsup.c-                /* See j9util_sched_compat_yield_value(), a space char is the null or error return */
openj9/runtime/rasdump/dmpsup.c-                if (' ' != schedCompatYieldValue) {
openj9/runtime/rasdump/dmpsup.c-                        /* allocate an item for the linked list */
openj9/runtime/rasdump/dmpsup.c-                        systemInfo = (J9RASSystemInfo *) j9mem_allocate_memory(sizeof(J9RASSystemInfo), OMRMEM_CATEGORY_VM);
openj9/runtime/rasdump/dmpsup.c-                        if (NULL != systemInfo) {
openj9/runtime/rasdump/dmpsup.c-                                /* populate the J9RASSystemInfo item and add it to the linked list */
openj9/runtime/rasdump/dmpsup.c-                                memset(systemInfo, '\0', sizeof(J9RASSystemInfo));
openj9/runtime/rasdump/dmpsup.c-                                systemInfo->key = J9RAS_SYSTEMINFO_SCHED_COMPAT_YIELD;
openj9/runtime/rasdump/dmpsup.c-                                ((char *)&systemInfo->data)[0] = schedCompatYieldValue;
openj9/runtime/rasdump/dmpsup.c-                                J9_LINKED_LIST_ADD_LAST(rasStruct->systemInfo, systemInfo);
openj9/runtime/rasdump/dmpsup.c-                        }
openj9/runtime/rasdump/dmpsup.c-                }
openj9/runtime/rasdump/dmpsup.c-        }
openj9/runtime/rasdump/dmpsup.c-        appendSystemInfoFromFile(vm, J9RAS_SYSTEMINFO_CORE_PATTERN, J9RAS_CORE_PATTERN_FILE);
openj9/runtime/rasdump/dmpsup.c-        appendSystemInfoFromFile(vm, J9RAS_SYSTEMINFO_CORE_USES_PID, J9RAS_CORE_USES_PID_FILE);
openj9/runtime/rasdump/dmpsup.c-#endif /* defined(LINUX) */
  1. This seems relevant to OSX. Signal handling works similarlu on Linux and OSX. To avoid a potential hang, this code should be enabled on OSX.
openj9/runtime/rasdump/dmpsup.c:/**
openj9/runtime/rasdump/dmpsup.c- * On Linux the first call to get a backtrace can cause some initialisation work.
openj9/runtime/rasdump/dmpsup.c- * If this is called in a signal handler with other threads paused then one of
openj9/runtime/rasdump/dmpsup.c- * those can hold a lock required for the initialisation to complete. This causes
openj9/runtime/rasdump/dmpsup.c- * a hang. Therefore we do one redundant call to backtrace at startup to prevent
openj9/runtime/rasdump/dmpsup.c- * java dumps hanging the VM.
openj9/runtime/rasdump/dmpsup.c- *
openj9/runtime/rasdump/dmpsup.c- * See defect 183803
openj9/runtime/rasdump/dmpsup.c- */
openj9/runtime/rasdump/dmpsup.c-static void
openj9/runtime/rasdump/dmpsup.c-initBackTrace(J9JavaVM *vm)
openj9/runtime/rasdump/dmpsup.c-{
openj9/runtime/rasdump/dmpsup.c-#ifdef LINUX
openj9/runtime/rasdump/dmpsup.c-        J9PlatformThread threadInfo;
openj9/runtime/rasdump/dmpsup.c-        J9Heap *heap;
openj9/runtime/rasdump/dmpsup.c-        char backingStore[8096];
openj9/runtime/rasdump/dmpsup.c-
openj9/runtime/rasdump/dmpsup.c-        PORT_ACCESS_FROM_JAVAVM(vm);
openj9/runtime/rasdump/dmpsup.c-
openj9/runtime/rasdump/dmpsup.c-        /* Use a local heap so the memory used for the backtrace is freed automatically. */
openj9/runtime/rasdump/dmpsup.c-        heap = j9heap_create(backingStore, sizeof(backingStore), 0);
openj9/runtime/rasdump/dmpsup.c-        if( j9introspect_backtrace_thread(&threadInfo, heap, NULL) != 0 ) {
openj9/runtime/rasdump/dmpsup.c-                j9introspect_backtrace_symbols(&threadInfo, heap);
openj9/runtime/rasdump/dmpsup.c-        }
openj9/runtime/rasdump/dmpsup.c-#endif
  1. On OSX, alloca function is defined in stdlib.h. so, alloca.h is not needed on OSX. Reference - compile error on freebsd / macosx due to missing 'alloca.h' h2o/h2o#47.
openj9/runtime/rasdump/javadump.cpp:#elif defined(LINUX) || defined(AIXPPC)
openj9/runtime/rasdump/javadump.cpp-#include <alloca.h>
openj9/runtime/rasdump/javadump.cpp-#elif defined(J9ZOS390)
  1. Need to add lldb variant as shown below.
openj9/runtime/rasdump/dmpagent.c:#elif defined(LINUX)
openj9/runtime/rasdump/dmpagent.c-                "gdb -p %pid",
openj9/runtime/rasdump/dmpagent.c-#elif defined(AIXPPC)
openj9/runtime/rasdump/dmpagent.c-                "dbx -a %pid",
openj9/runtime/rasdump/dmpagent.c-#elif defined(J9ZOS390)
openj9/runtime/rasdump/dmpagent.c-                "dbx -a %pid",
openj9/runtime/rasdump/dmpagent.c-#elif defined(OSX)
openj9/runtime/rasdump/dmpagent.c-                "lldb -p %pid",
openj9/runtime/rasdump/dmpagent.c-#else
openj9/runtime/rasdump/dmpagent.c-                NULL,
openj9/runtime/rasdump/dmpagent.c-#endif
  1. The below code should also be enabled on OSX. fork, execl and waitpid exist on OSX.
openj9/runtime/rasdump/dmpagent.c:/*
openj9/runtime/rasdump/dmpagent.c- * Function: doToolDump - launches a tool command as specified via a -Xdump:tool agent
openj9/runtime/rasdump/dmpagent.c- *
openj9/runtime/rasdump/dmpagent.c- * Parameters:
openj9/runtime/rasdump/dmpagent.c- *  agent [in]         - dump agent structure
openj9/runtime/rasdump/dmpagent.c- *  label [in]         - tool command to be executed
openj9/runtime/rasdump/dmpagent.c- *  context [in] - dump context (what triggered the dump)
openj9/runtime/rasdump/dmpagent.c- *
openj9/runtime/rasdump/dmpagent.c- * Returns: OMR_ERROR_NONE, OMR_ERROR_INTERNAL
openj9/runtime/rasdump/dmpagent.c- */
openj9/runtime/rasdump/dmpagent.c-omr_error_t
openj9/runtime/rasdump/dmpagent.c-doToolDump(J9RASdumpAgent *agent, char *label, J9RASdumpContext *context)
openj9/runtime/rasdump/dmpagent.c-{
openj9/runtime/rasdump/dmpagent.c-....
openj9/runtime/rasdump/dmpagent.c-#elif (defined(LINUX) && !defined(J9ZTPF)) || defined(AIXPPC)
openj9/runtime/rasdump/dmpagent.c-              {
openj9/runtime/rasdump/dmpagent.c-                      IDATA retVal;
openj9/runtime/rasdump/dmpagent.c-
openj9/runtime/rasdump/dmpagent.c-                      if ( (retVal = fork()) == 0 ) {
openj9/runtime/rasdump/dmpagent.c-
openj9/runtime/rasdump/dmpagent.c-                              retVal = execl("/bin/sh", "/bin/sh", "-c", label, NULL);
openj9/runtime/rasdump/dmpagent.c-
openj9/runtime/rasdump/dmpagent.c-                              j9nls_printf(PORTLIB, J9NLS_ERROR | J9NLS_STDERR, J9NLS_DMP_ERROR_IN_DUMP_STR_RC, "Tool", "execl()", errno);
openj9/runtime/rasdump/dmpagent.c-                              exit( (int)retVal );
openj9/runtime/rasdump/dmpagent.c-
openj9/runtime/rasdump/dmpagent.c-                      } else {
openj9/runtime/rasdump/dmpagent.c-                              j9nls_printf(PORTLIB, J9NLS_INFO | J9NLS_STDERR, J9NLS_DMP_SPAWNED_DUMP_STR, "Tool", retVal);
openj9/runtime/rasdump/dmpagent.c-
openj9/runtime/rasdump/dmpagent.c-                              /* Give it a chance to start */
openj9/runtime/rasdump/dmpagent.c-                              if (async == FALSE) {
openj9/runtime/rasdump/dmpagent.c-                                      waitpid(retVal, NULL, 0);
openj9/runtime/rasdump/dmpagent.c-                              }
openj9/runtime/rasdump/dmpagent.c-                              omrthread_sleep(msec);
openj9/runtime/rasdump/dmpagent.c-                      }
openj9/runtime/rasdump/dmpagent.c-              }
  1. The below code is used in fixDumpLabel. It is relevant for OSX, and should be enabled. getcwd exists on OSX.
openj9/runtime/rasdump/dmpagent.c:#elif defined(LINUX) || defined(AIXPPC)
openj9/runtime/rasdump/dmpagent.c-                              ok = (getcwd(prefix, J9_MAX_DUMP_PATH) != 0);
openj9/runtime/rasdump/dmpagent.c-#elif defined(J9ZOS390)
@babsingh
Copy link
Contributor Author

fyi - @pshipton @DanHeidinga

related to #36.

@pdbain-ibm
Copy link
Contributor

@babsingh is 8. (above) related to issue #3343?

@babsingh
Copy link
Contributor Author

@pdbain-ibm yes, it is related to [8]; -Xdump:system:file=j9core.dmp,events=vmstop won't get processed properly on OSX.

babsingh added a commit to babsingh/openj9 that referenced this issue Oct 24, 2018
More details here: eclipse-openj9#3380.

closes: eclipse-openj9#3380.
closes: eclipse-openj9#3343.

Signed-off-by: Babneet Singh <[email protected]>
acrowthe pushed a commit to acrowthe/openj9 that referenced this issue Nov 5, 2018
More details here: eclipse-openj9#3380.

closes: eclipse-openj9#3380.
closes: eclipse-openj9#3343.

Signed-off-by: Babneet Singh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants