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

hwloc_get_last_cpu_location fails in chroot when /proc not mounted #214

Closed
bgoglin opened this issue Oct 28, 2016 · 6 comments
Closed

hwloc_get_last_cpu_location fails in chroot when /proc not mounted #214

bgoglin opened this issue Oct 28, 2016 · 6 comments

Comments

@bgoglin
Copy link
Contributor

bgoglin commented Oct 28, 2016

(moved from @dgloe second comment of #213 to here)

When I try again with debugging information turned on I get a different error:

hwloc_get_last_cpu_location: hwloc_get_last_cpu_location.c:28: check: Assertion `!ret' failed.
./wrapper.sh: line 14: 20654 Aborted                 (core dumped) "$@"
@bgoglin
Copy link
Contributor Author

bgoglin commented Oct 28, 2016

What kind of debug did you enable? Compiler options? Or hwloc --enable-debug? I don't see why debugging would change anything here. This function shouldn't check. Can you printf errno?

@dgloe
Copy link

dgloe commented Oct 28, 2016

By enabling debugging I just mean adding -g to CFLAGS so I can get information out of the core file.

@dgloe
Copy link

dgloe commented Oct 28, 2016

The errno value is 38.

@bgoglin
Copy link
Contributor Author

bgoglin commented Oct 28, 2016

Try this. If it fails to build, we need to see if SYS_gettid was moved somewhere else, or is just missing for real. If it builds, you'll get a print, hopfully.

diff --git a/src/topology-linux.c b/src/topology-linux.c
index 26bde8e..bea4c9b 100644
--- a/src/topology-linux.c
+++ b/src/topology-linux.c
@@ -1014,6 +1014,7 @@ hwloc_linux_get_tid_last_cpu_location(hwloc_topology_t topology __hwloc_attribut
 #ifdef SYS_gettid
     tid = syscall(SYS_gettid);
 #else
+#error no SYS_gettid
     errno = ENOSYS;
     return -1;
 #endif
@@ -1022,18 +1023,21 @@ hwloc_linux_get_tid_last_cpu_location(hwloc_topology_t topology __hwloc_attribut
   snprintf(name, sizeof(name), "/proc/%lu/stat", (unsigned long) tid);
   file = fopen(name, "r");
   if (!file) {
+printf("fopen %s %s\n", name, strerror(errno));
     errno = ENOSYS;
     return -1;
   }
   tmp = fgets(buf, sizeof(buf), file);
   fclose(file);
   if (!tmp) {
+printf("fgets %s\n", strerror(errno));
     errno = ENOSYS;
     return -1;
   }

   tmp = strrchr(buf, ')');
   if (!tmp) {
+printf("strrchr failed\n");
     errno = ENOSYS;
     return -1;
   }
@@ -1044,6 +1048,7 @@ hwloc_linux_get_tid_last_cpu_location(hwloc_topology_t topology __hwloc_attribut
   for(i=0; i<36; i++) {
     tmp = strchr(tmp, ' ');
     if (!tmp) {
+printf("strchr %u failed\n", i);
       errno = ENOSYS;
       return -1;
     }
@@ -1053,6 +1058,7 @@ hwloc_linux_get_tid_last_cpu_location(hwloc_topology_t topology __hwloc_attribut

   /* read the last cpu in the 38th field now */
   if (sscanf(tmp, "%d ", &i) != 1) {
+printf("sscanf %s failed\n", tmp);
     errno = ENOSYS;
     return -1;
   }

@dgloe
Copy link

dgloe commented Oct 28, 2016

fopen /proc/25645/stat No such file or directory

Looks like the chroot didn't have the /proc filesystem set up.
Executing mount -t proc proc proc/ fixed the issue.

@bgoglin bgoglin changed the title hwloc_get_last_cpu_location test failing in SLES 12 build root hwloc_get_last_cpu_location fails in chroot when /proc not mounted Oct 28, 2016
@bgoglin
Copy link
Contributor Author

bgoglin commented Oct 28, 2016

Thanks, I retitled for documentation and I am closing now.

@bgoglin bgoglin closed this as completed Oct 28, 2016
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

No branches or pull requests

2 participants