https://bugs.llvm.org/show_bug.cgi?id=35137

            Bug ID: 35137
           Summary: ASan strotol interceptor breaks errno on Windows
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: compiler-rt
          Assignee: unassignedb...@nondot.org
          Reporter: r...@google.com
                CC: llvm-bugs@lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to