<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - LLVM ERROR: IO failure on output stream: Bad file descriptor"
   href="https://bugs.llvm.org/show_bug.cgi?id=41984">41984</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLVM ERROR: IO failure on output stream: Bad file descriptor
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>llvm-dsymutil
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tommaso.piazza@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>aprantl@apple.com, friss@apple.com, jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Running dsymutil on a FAT macho binary with > 4 architectures causes IO
failure. 

Architectures in questions are: x84_64, i386, arm_v7, arm_v7s, arm64

Everything works fine if -num-threads=1 or if architectures <= 4 

I have verified this with dsymutil shipped with Xcode 10.2.x toolchain on
Mojave 10.4.4 and with dsymutil built from source (github).

I couldn't attach the binary to this ticket so I have uploaded it here:
<a href="https://mega.nz/#!39dFyCbD!2EVXvCmySdzFdMfxUhRu0TIRxGEI6n4UvssGWGOuCdE">https://mega.nz/#!39dFyCbD!2EVXvCmySdzFdMfxUhRu0TIRxGEI6n4UvssGWGOuCdE</a>

I have tried to debug the issue. I am by no means knowledgeable in C++ or llvm
but I have noticed that changing the value to 5 here
<a href="https://github.com/llvm/llvm-project/blob/master/llvm/tools/dsymutil/dsymutil.cpp#L539">https://github.com/llvm/llvm-project/blob/master/llvm/tools/dsymutil/dsymutil.cpp#L539</a>
solves the issue. I am guessing this doesn't scale though.

Also, the 'help' text for -num-treads is wrong. It's a binary flag in the
source code. The actual number of threads is always either 1 or max supported
by hardware and never the amount specified on the CLI.
<a href="https://github.com/llvm/llvm-project/blob/master/llvm/tools/dsymutil/dsymutil.cpp#L369">https://github.com/llvm/llvm-project/blob/master/llvm/tools/dsymutil/dsymutil.cpp#L369</a>
there should be an else here with Options.Threads = NumThreads

See also: <a href="https://github.com/Carthage/Carthage/issues/2738">https://github.com/Carthage/Carthage/issues/2738</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>