<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 - ASan strotol interceptor breaks errno on Windows"
   href="https://bugs.llvm.org/show_bug.cgi?id=35137">35137</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ASan strotol interceptor breaks errno on Windows
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>compiler-rt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Running this program on Windows prints "errno: 34" without asan and "errno: 0"
with asan:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
void print_strtol_results(const char *input) {
  char *end = 0;
  long result = strtol(input, &end, 10);
  int err = errno;
  printf("input: %s, end: %s, result: %ld, errno: %d\n", input, end, result,
err);
}
int main() {
  //print_strtol_results("2147483647");
  print_strtol_results("2147483648");
  printf("&errno: %p, errno: %d\n", &errno, errno);
  return 0;
}

This is because ASan intercepts many versions of strtol and redirects them all
to itself. It then delegates to ntdll!strtol, which doesn't set errno, because
errno is a CRT concept, and ntdll is layered below the CRT.</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>