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

3.0.0rc2: FreeBSD: divide-by-zero in hwloc #3992

Closed
hppritcha opened this issue Aug 1, 2017 · 33 comments
Closed

3.0.0rc2: FreeBSD: divide-by-zero in hwloc #3992

hppritcha opened this issue Aug 1, 2017 · 33 comments
Assignees
Milestone

Comments

@hppritcha
Copy link
Member

@PHHargrove reported a problem bubbling up from hwloc when testing 3.0.0rc2 on
FreeBSD/amd64:

On FreeBSD-11/amd64:

$ mpirun -mca btl vader,self -np 2 examples/ring_c
[freebsd-amd64:25312] *** Process received signal ***
[freebsd-amd64:25312] Signal: Floating point exception (8)
[freebsd-amd64:25312] Signal code: Integer divide-by-zero (2)
[freebsd-amd64:25312] Failing at address: 0x800c13822
[freebsd-amd64:25312] [ 0] 0x8016e5934 <pthread_sigmask+0x544> at /lib/libthr.so.3
[freebsd-amd64:25312] [ 1] 0x8016e4ecf <pthread_getspecific+0xe5f> at /lib/libthr.so.3
[freebsd-amd64:25312] *** End of error message ***

reported on devel mail list:
https://www.mail-archive.com/devel@lists.open-mpi.org//msg20326.html

@PHHargrove
Copy link
Member

If I configure using --with-hwloc=/usr/local I get hwloc-1.11.7 (newer than the embedded 1.11.3) and the problem does not occur. The FreeBSD ports tree does not appear to be applying any patches of its own. So, there is potentially an upstream fix that can be cherry-picked.

Alternatively, README could suggest installing/using an external hwloc.

In case it matters, this is a KVM-based virtual machine.
Output of lstopo (from FreeBSD's 1.11.7):

$ lstopo -v
Machine (P#0 local=3112740KB total=3112740KB Backend=FreeBSD OSName=FreeBSD OSRelease=11.1-RELEASE OSVersion="FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 02:08:28 UTC 2017     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC" HostName=freebsd-amd64 Architecture=amd64 Backend=x86 hwlocVersion=1.11.7 ProcessName=lstopo)
  Package L#0 (P#0 CPUVendor=AuthenticAMD CPUFamilyNumber=6 CPUModelNumber=6 CPUModel="QEMU Virtual CPU version 2.5+" CPUStepping=3)
    L2Cache L#0 (P#0 size=512KB linesize=64 ways=16 Inclusive=0)
      L1dCache L#0 (P#0 size=64KB linesize=64 ways=2 Inclusive=0)
        L1iCache L#0 (P#0 size=64KB linesize=64 ways=2 Inclusive=0)
          Core L#0 (P#0)
            PU L#0 (P#0)
  Package L#1 (P#1 CPUVendor=AuthenticAMD CPUFamilyNumber=6 CPUModelNumber=6 CPUModel="QEMU Virtual CPU version 2.5+" CPUStepping=3)
    L2Cache L#1 (P#1 size=512KB linesize=64 ways=16 Inclusive=0)
      L1dCache L#1 (P#1 size=64KB linesize=64 ways=2 Inclusive=0)
        L1iCache L#1 (P#1 size=64KB linesize=64 ways=2 Inclusive=0)
          Core L#1 (P#0)
            PU L#1 (P#1)
depth 0:        1 Machine (type #1)
 depth 1:       2 Package (type #3)
  depth 2:      2 L2Cache (type #4)
   depth 3:     2 L1dCache (type #4)
    depth 4:    2 L1iCache (type #4)
     depth 5:   2 Core (type #5)
      depth 6:  2 PU (type #6)

@bwbarrett
Copy link
Member

Interesting; I can't replicate on EC2 with 11.0; wonder if something changed between 11.0 and 11.1 or if it's something in the QEMU processor emulation.

$ mpirun -mca btl vader,self -np 2 ./ring_c
Process 0 sending 10 to 1, tag 201 (2 processes in ring)
Process 0 sent to 1
Process 0 decremented value: 9
Process 0 decremented value: 8
Process 0 decremented value: 7
Process 0 decremented value: 6
Process 0 decremented value: 5
Process 0 decremented value: 4
Process 0 decremented value: 3
Process 0 decremented value: 2
Process 0 decremented value: 1
Process 0 decremented value: 0
Process 0 exiting
Process 1 exiting
$ lstopo -v
Machine (P#0 local=31424180KB total=31424180KB Backend=FreeBSD OSName=FreeBSD OSRelease=11.0-RELEASE-p9 OSVersion="FreeBSD 11.0-RELEASE-p9 #0: Tue Apr 11 08:48:40 UTC 2017     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC" HostName=ip-172-31-57-222 Architecture=amd64 Backend=x86 hwlocVersion=1.11.7 ProcessName=lstopo)
  Package L#0 (P#0 CPUVendor=GenuineIntel CPUFamilyNumber=6 CPUModelNumber=63 CPUModel="Intel(R) Xeon(R) CPU E5-2666 v3 @ 2.90GHz" CPUStepping=2)
    L3Cache L#0 (P#0 size=25600KB linesize=64 ways=20 Inclusive=1)
      L2Cache L#0 (P#0 size=256KB linesize=64 ways=8 Inclusive=0)
        L1dCache L#0 (P#0 size=32KB linesize=64 ways=8 Inclusive=0)
          L1iCache L#0 (P#0 size=32KB linesize=64 ways=8 Inclusive=0)
            Core L#0 (P#0)
              PU L#0 (P#0)
              PU L#1 (P#1)
      L2Cache L#1 (P#1 size=256KB linesize=64 ways=8 Inclusive=0)
        L1dCache L#1 (P#1 size=32KB linesize=64 ways=8 Inclusive=0)
          L1iCache L#1 (P#1 size=32KB linesize=64 ways=8 Inclusive=0)
            Core L#1 (P#1)
              PU L#2 (P#2)
              PU L#3 (P#3)
      L2Cache L#2 (P#2 size=256KB linesize=64 ways=8 Inclusive=0)
        L1dCache L#2 (P#2 size=32KB linesize=64 ways=8 Inclusive=0)
          L1iCache L#2 (P#2 size=32KB linesize=64 ways=8 Inclusive=0)
            Core L#2 (P#2)
              PU L#4 (P#4)
              PU L#5 (P#5)
      L2Cache L#3 (P#3 size=256KB linesize=64 ways=8 Inclusive=0)
        L1dCache L#3 (P#3 size=32KB linesize=64 ways=8 Inclusive=0)
          L1iCache L#3 (P#3 size=32KB linesize=64 ways=8 Inclusive=0)
            Core L#3 (P#3)
              PU L#6 (P#6)
              PU L#7 (P#7)
      L2Cache L#4 (P#4 size=256KB linesize=64 ways=8 Inclusive=0)
        L1dCache L#4 (P#4 size=32KB linesize=64 ways=8 Inclusive=0)
          L1iCache L#4 (P#4 size=32KB linesize=64 ways=8 Inclusive=0)
            Core L#4 (P#4)
              PU L#8 (P#8)
              PU L#9 (P#9)
      L2Cache L#5 (P#5 size=256KB linesize=64 ways=8 Inclusive=0)
        L1dCache L#5 (P#5 size=32KB linesize=64 ways=8 Inclusive=0)
          L1iCache L#5 (P#5 size=32KB linesize=64 ways=8 Inclusive=0)
            Core L#5 (P#5)
              PU L#10 (P#10)
              PU L#11 (P#11)
      L2Cache L#6 (P#6 size=256KB linesize=64 ways=8 Inclusive=0)
        L1dCache L#6 (P#6 size=32KB linesize=64 ways=8 Inclusive=0)
          L1iCache L#6 (P#6 size=32KB linesize=64 ways=8 Inclusive=0)
            Core L#6 (P#6)
              PU L#12 (P#12)
              PU L#13 (P#13)
      L2Cache L#7 (P#7 size=256KB linesize=64 ways=8 Inclusive=0)
        L1dCache L#7 (P#7 size=32KB linesize=64 ways=8 Inclusive=0)
          L1iCache L#7 (P#7 size=32KB linesize=64 ways=8 Inclusive=0)
            Core L#7 (P#7)
              PU L#14 (P#14)
              PU L#15 (P#15)
depth 0:	1 Machine (type #1)
 depth 1:	1 Package (type #3)
  depth 2:	1 L3Cache (type #4)
   depth 3:	8 L2Cache (type #4)
    depth 4:	8 L1dCache (type #4)
     depth 5:	8 L1iCache (type #4)
      depth 6:	8 Core (type #5)
       depth 7:	16 PU (type #6)

@rhc54
Copy link
Contributor

rhc54 commented Aug 4, 2017

Is there any reason not to update to 1.11.7? I ask because there are some improvements and bug fixes in those latter releases that are good to have. I'm willing to roll the PR if you want it.

@bwbarrett
Copy link
Member

@rhc54, I don't think so; just the usual wanting to get something out the door. But if that's the easiest way to get this bug removed, then let's do that.

@PHHargrove
Copy link
Member

I've tried #4022, but the problem persists. Perhaps I was wrong when I concluded that no patches were applied to the hwloc build in the FreeBSD package repo.

The fastest way to get 3.0 out the door seems to me to be to simply document that --with-hwloc=/usr/local is necessary. Unfortunately, beween Brian's FreeBSD-11.0+EC2 results and my FreeBSD-11.1+KVM results, we are left uncertain if the O/S or QEMU is the key factor.

If one does want to continue chasing this bug, here is something new... it looks like the hwloc cache is all zeros at the time of the crash:

#0  0x0000000800c1395e in look_proc (backend=0x8026264a0, infos=0x802690500, highest_cpuid=13,
    highest_ext_cpuid=2147483658, features=0x7fffffffdcd0, cpuid_type=57921536)
    at ../../../../../../../../opal/mca/hwloc/hwloc1117/hwloc/src/topology-x86.c:482
482         cache->cacheid = infos->apicid / cache->nbthreads_sharing;
(gdb) print *cache
$1 = {type = 0, level = 0, nbthreads_sharing = 0, cacheid = 0, linesize = 0, linepart = 0, inclusive = 0,  ways = 0, sets = 0, size = 0}

@rhc54
Copy link
Contributor

rhc54 commented Aug 6, 2017

@bgoglin Any thoughts?

@bgoglin
Copy link
Contributor

bgoglin commented Aug 7, 2017

I am not aware of any patch being applied to FreeBSD hwloc.

@PHHargrove when cache->type == 0, we ignore the cache, you shouldn't ever use that cache in the code. I have a FreeBSD 11.1 running on KVM, no problem. But it may depend on the underlying hardware since we are in the cpuid/x86 code here. Can you run hwloc-gather-cpuid from hwloc git master and send the resulting cpuid directory? I can debug remotely from there.

@PHHargrove
Copy link
Member

@bgoglin
hwloc-gather-cpuid from hwloc git master SEGVs:

Program terminated with signal 11, Segmentation fault.
Reading symbols from /home/phargrov/hwloc/BLD/hwloc/.libs/libhwloc.so.0...done.
Loaded symbols for /home/phargrov/hwloc/BLD/hwloc/.libs/libhwloc.so.0
[...]
#0  hwloc_look_x86 (backend=0x802040050, fulldiscovery=<value optimized out>) at ../../hwloc/topology-x86.c:63
63        if (cpuiddump->nr)
(gdb) where
#0  hwloc_look_x86 (backend=0x802040050, fulldiscovery=<value optimized out>) at ../../hwloc/topology-x86.c:63
#1  0x000000080084cf87 in hwloc_x86_discover (backend=0x802040050) at ../../hwloc/topology-x86.c:1257
#2  0x000000080082fafa in hwloc_topology_load (topology=0x80201c000) at ../../hwloc/topology.c:2609
#3  0x000000000040115f in main (argc=<value optimized out>, argv=0x7fffffffe9f0)
    at ../../../utils/hwloc/hwloc-gather-cpuid.c:378

@bgoglin
Copy link
Contributor

bgoglin commented Aug 7, 2017

Ergl, it likely fails for similar reasons. Can you set HWLOC_COMPONENTS=-x86 in the environment before running?

@PHHargrove
Copy link
Member

@bgoglin tarball of cpuid directory will be sent by email shortly.

@bgoglin
Copy link
Contributor

bgoglin commented Aug 7, 2017

Thanks. One thing that seems strange is that the VM exposes an AMD with cache information in both AMD and Intel CPUID leaves. Our code is supposed to ignore Intel-specific caches on non-Intel but I am not sure we have ever tested that.

Any chance you give me access to the VM? Or any way to share the image of the VM on a ffile sharing website?

If we have to stay in your own gdb, I would like to see cpuid_type, highest_cpuid, highest_ext_cpuid, cachenum, infos->numcaches and then infos->cache[i] with i from 0 to numcaches-1.

@PHHargrove
Copy link
Member

@bgoglin VM access is possible. Switching to private email.

@bgoglin
Copy link
Contributor

bgoglin commented Aug 8, 2017

I am on the VM but I can't reproduce any single crash with 1.11.3, 1.11.7 or git master. Even hwloc-gather-cpuid works fine. Do you have anything in your environment and/or on your configure command-line? Note that I only tried lstopo from vanilla hwloc, nothing from OMPI's hwloc.

@PHHargrove
Copy link
Member

@bgoglin Output of "env" (with one redaction) is below.
The empty USERNAME is not a redaction - it really is empty in my environment.

Another possible difference is that I am a member of the system group "wheel", but I've ruled that out by removing myself.

My configure command line for master was empty on the first try, and I added --enable-debug after the first SEGV.

SSH_CONNECTION=172.16.254.1 53936 172.16.3.7 22
USERNAME=
CVSROOT=##############
SSH_AUTH_SOCK=/tmp/ssh-6Fvycwy5h7/agent.66348
USER=phargrov
PWD=/home/phargrov/hwloc/BLD
HOME=/home/phargrov
SSH_CLIENT=172.16.254.1 53936 22
BASH_ENV=/home/phargrov/.bashrc
SSH_TTY=/dev/pts/0
MAIL=/var/mail/phargrov
SHELL=/usr/local/bin/bash
TERM=screen
SHLVL=1
PRINTER=b50a2135d
BLOCKSIZE=K
LESSCHARSET=latin1
LOGNAME=phargrov
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/phargrov/bin
PS1={\u@\h \w}\$
RSYNC_RSH=ssh -a -x
LAMRSH=ssh -a -x
CVS_RSH=ssh
_=/usr/bin/env
OLDPWD=/home/phargrov/hwloc

@jsquyres and @bwbarrett can have a nice chuckle at the fact that LAMRSH is still set in the .bashrc I propagate to new systems 😁

@PHHargrove
Copy link
Member

@bgoglin
CORRECTION:
I had configured with CC=cc CXX=c++ to ensure use of the system default clang compilers (in /usr/bin), rather than gcc in /usr/local/bin.
Without these options to configure, hwloc defaults to use of gcc and g++ and no SEGV occurs.

@bgoglin
Copy link
Contributor

bgoglin commented Aug 8, 2017

Ah! I had to install gcc on my FreeBSD11 VM too because cc/clang was causing strange segfaults that moved around when adding printf.

@rhc54
Copy link
Contributor

rhc54 commented Aug 8, 2017

@PHHargrove so does that mean that your system hwloc in /usr/local was built with gcc and not clang? It sounds like the problem is in the clang compiler for that VM.

@PHHargrove
Copy link
Member

@rhc54 No, I've confirmed that the system hwloc-1.11.7 is built w/ CC=cc CXX=c++.
It is possible that the SEGV in hwloc-gather-cpuid (master) and the original divide-by-zero (1.11.3) are unrelated.

Keep in mind that (like Apple), the FreeBSD folks have adopted Clang as their official compiler, and gcc is just an add-on. Theor openmpi2 (2.0.2, FWIW) package is also built w/ Clang. So, that is the compiler I would prefer to test RCs against.

@bgoglin
Copy link
Contributor

bgoglin commented Aug 8, 2017

My hwloc 1.11.7 built with cc/c++ fails miserably. gdb shows things that make no sense. And adding debug printf makes the stack get crazy and segfaults move around.

All these failures occur in topology-x86.c which is the only lib file that uses inline asm for cpuid. So maybe clang doesn't like our asm. And hwloc-gather-cpuid also uses that asm.

Do you guys test things with clang/Linux?

@rhc54
Copy link
Contributor

rhc54 commented Aug 8, 2017

yes, the various CI and some MTT tests are done against it

@rhc54
Copy link
Contributor

rhc54 commented Aug 8, 2017

I'm just poking to understand what action needs to be done in response to all this info. I'm not sure I see it yet.

@PHHargrove
Copy link
Member

@rhc54
Since FreeBSD comes with clang and not gcc, one could argue that is the compiler that should be supported. However, if Brice is confident that clang is buggy (or simply not practical to support) then you may need to document that gcc is a requirement.

@rhc54
Copy link
Contributor

rhc54 commented Aug 9, 2017

Actually, I had a slightly different perspective in mind. I have installed clang 3.4.2 on my CentOS7 box and confirmed that we both build against it and can run without issue (not a surprise as our CI regularly tests against clang). My question, therefore, was whether the FreeBSD clang compiler on your VM might somehow be borked, and thus we should simply ignore that failure.

@PHHargrove
Copy link
Member

@rhc54 One comment from @bgoglin seems to indicate clang is giving him problems on FreeBSD as well. So this is not isolated to "my" VM.

This is the system compiler we are talking about here.
The FreeBSD kernel and all of /bin and /usr/bin are built with it, plus hundreds (thousands?) of packages in the Ports tree are built with it.
So, if it were fundamentally flawed, it would not have made it to release.

I am not sure what sounds best as a path forward for 3.0.0 on FreeBSD

@bgoglin
Copy link
Contributor

bgoglin commented Aug 10, 2017

@PHHargrove if you're planning to report a bug against FreeBSD 11.1, I'd like to see it (in case I can generate a small testcase with the hwloc x86 cpuid code).

@PHHargrove
Copy link
Member

@bgoglin I don't have current plans to file a bug report because (a) I don't have time and (b) without a reduced test case I don't think the bug would get any attention. If you can produce a reduced testcase, I can probably make time to collaborate on submitting the bug report.

@rhc54 I think this is a documentation issue for both 3.0.0 and 2.1.2. My suggestion:

The system compiler (clang-4.0) on FreeBSD-11.1/amd64 is believed to compile hwloc incorrectly.
As a result, one cannot build a working Open MPI without the installation of external packages.
There are at least two options:

  1. Install gcc. This is also necessary if one requires a fortran compiler.
  2. Install hwloc from the binary BSD packages repository (where it was build with gcc) and configure Open MPI using --with-hwloc=/usr/local.

@rhc54
Copy link
Contributor

rhc54 commented Aug 11, 2017

@hppritcha @bwbarrett I concur with the documentation suggestion, but it's up to you folks

@hppritcha hppritcha assigned hppritcha and unassigned bwbarrett Aug 15, 2017
@hppritcha
Copy link
Member Author

I'll do a README update

hppritcha added a commit to hppritcha/ompi that referenced this issue Aug 15, 2017
The clang 4.0 compiler that ships with FreeBSD 11.1 doesn't
work well with hwloc (older than 1.11.7), so if the following conditions hold

- one is building a version of Open MPI to include the internal hwloc package
- and the version of Open MPI's internal hwloc package is older than 1.11.7
- using the clang 4.0 compiler that ships with this release of FreeBSD

then one may observe segfaults, floating pointer exceptions, etc.

One workaround is to use the GNU compiler.

Related to open-mpi#3992.
[skip ci]

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
hppritcha added a commit to hppritcha/ompi that referenced this issue Aug 16, 2017
The clang 4.0 compiler that ships with FreeBSD 11.1 doesn't
work well with hwloc packaged with OpenMPI.  Workaround is
to use a GNU compiler.

Related to open-mpi#3992.
[skip ci]

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
@PHHargrove
Copy link
Member

In testing 2.1.2rc3 I have again found /usr/bin/cc (clang) on FreeBSD-11.1/amd64 to be leading to unexpected SEGVs. See https://www.mail-archive.com/devel@lists.open-mpi.org/msg20351.html

I believe it would be appropriate to remove the Blocker tag (and perhaps Bug, too) from this issue, since it seems to be entirely due to external problems, which Howard documented in 800a971

Note that unless I missed it, something still needs to go in the 2.1.2 README.

hppritcha added a commit to hppritcha/ompi that referenced this issue Aug 31, 2017
The clang 4.0 compiler that ships with FreeBSD 11.1 doesn't
work well with OpenMPI.  Workaround is to use a GNU compiler.

Related to open-mpi#3992.
[skip ci]

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
@hppritcha
Copy link
Member Author

this problem seems to be fairly generic across multiple releases, so adding more tags.

hppritcha added a commit to hppritcha/ompi that referenced this issue Sep 5, 2017
The clang 4.0 compiler that ships with FreeBSD 11.1 doesn't
work well with OpenMPI.  Workaround is to use a GNU compiler.

Related to open-mpi#3992.
[skip ci]

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
(cherry picked from commit 083e6e6)
hppritcha added a commit to hppritcha/ompi that referenced this issue Sep 5, 2017
The clang 4.0 compiler that ships with FreeBSD 11.1 doesn't
work well with OpenMPI.  Workaround is to use a GNU compiler.

Related to open-mpi#3992.
[skip ci]

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
(cherry picked from commit 083e6e6)
hppritcha added a commit to hppritcha/ompi that referenced this issue Sep 5, 2017
The clang 4.0 compiler that ships with FreeBSD 11.1 doesn't
work well with OpenMPI.  Workaround is to use a GNU compiler.

Related to open-mpi#3992.
[skip ci]

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
(cherry picked from commit 083e6e6)
@bwbarrett bwbarrett modified the milestones: v2.1.2, v3.0.0 Sep 5, 2017
@bwbarrett
Copy link
Member

The 3.0 NEWS blurb is updated. Moving the milestone to 2.1 to track that NEWS blurb.

hppritcha added a commit to hppritcha/ompi that referenced this issue Sep 6, 2017
The clang 4.0 compiler that ships with FreeBSD 11.1 doesn't
work well with OpenMPI.  Workaround is to use a GNU compiler.

Related to open-mpi#3992.
[skip ci]

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
(cherry picked from commit 083e6e6)
@hppritcha
Copy link
Member Author

committed to all four branches. closing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants