Bug 273086

Summary: clock_gettime(CLOCK_MONOTONIC_COARSE, *struct timespec) fails with 32bit program on 64bit machine
Product: Base System Reporter: Minsoo Choo <minsoochoo0122>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed DUPLICATE    
Severity: Affects Many People CC: freebsd
Priority: ---    
Version: 13.2-RELEASE   
Hardware: amd64   
OS: Any   

Description Minsoo Choo 2023-08-12 15:18:13 UTC
$ cat main.c
#include <stdio.h>
#include <time.h>

int main() {
  struct timespec ts;

  for (int i = 0; i < 100; ++i) {
    clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
    printf("%d %ld\n", ts.tv_sec, ts.tv_nsec);
  }
  return 0;
}

$ cc -m32 main.c
$ ./a.out
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
....


This happens when building the program as 32bit executable on 64bit FreeBSD and run the executable on 64bit FreeBSD.
Comment 1 Mina Galić freebsd_triage 2023-08-12 15:35:29 UTC

*** This bug has been marked as a duplicate of bug 273085 ***