On Wed, Jul 20, 2022 at 08:20:27PM +0200, grischka wrote: > On 20.07.2022 06:03, Arthur Williams via Tinycc-devel wrote: > > Hi, > > > > Was writing an application and noticed a bug. The script can be reduced > > to the following: > > > > ``` > > #!/bin/tcc -run > > #include <time.h> > > int main() { > > struct timespec start, current; > > clock_gettime(CLOCK_MONOTONIC, &start); // Segfaults > > } > > ``` > > > > When the file is executed, it crashes at the indicated line. If I > > explicitly compile the program and run it, it behaves correctly. Also tested > > the same script on a glibc based machine and it also didn't crash. > > > > Not sure exactly what's special about the call to `clock_gettime`, but > > replacing it with something trivial or a printf avoids the crash. > > Maybe tcc and the system disagree about the sizeof (struct timespec) ? > > -- gr
When compiling via tcc with '-run' and without it, sizeof(struct timespec) is the same (16). I did attempt to generate a backtrace to debug. However, I got the following errors ``` tcc: error: undefined symbol 'strchr' tcc: error: undefined symbol 'stderr' tcc: error: undefined symbol 'fprintf' tcc: error: undefined symbol 'fflush' ``` when I changed the shebang to '#!/bin/tcc -run -g -bt4'. Probably should have first stated that I was using 1.2.2. Upgrading to 1.2.3 didn't change the behavior though. Arthur _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel