Bug #876 configure bug causes build failure on FreeBSD 5.1
Submitted: 18 Jul 2003 19:23 Modified: 19 Jul 2003 1:32
Reporter: [ name withheld ] Email Updates:
Status: Closed
Category:Server: Compiling Severity:S2 (Serious)
Version:3.23.57 OS:FreeBSD (FreeBSD 5.1-RELEASE)
Assigned to: Target Version:

[18 Jul 2003 19:23] [ name withheld ]
Description:
There is a bug in the configure script for mysql 3.23.57.  One of the configure tests
involves compiling and running the following file.  It comes from acinclude.m4 around
line 613, under the test MYSQL_CHECK_LONGLONG_TO_FLOAT.

#include <stdio.h>
typedef long long longlong;
main()
{
  longlong ll=1;
  float f;
  FILE *file=fopen("conftestval", "w");
  f = (float) ll;
  fprintf(file,"%g\n",f);
  close(file);
  exit (0);
}

Obviously the `close' on the third-to-last line should be an `fclose'.

On most systems the bogus close will fail with EBADF, which will be ignored, and there is
no real problem.  However, under FreeBSD 5.1, due to a quirk in the reentrant libc, this
actually causes a segfault, and as a result `configure' fails and mysql cannot be built. 
This libc behavior is arguably incorrect, but nevertheless the `close' call is certainly
incorrect and IMHO should be fixed.

Also, it might be a good idea to check the return value from `fopen', so as not to
segfault if for some reason the file cannot be opened.

I'm calling this "serious" because it keeps you from building mysql on this platform, but
please alter the severity if it's not appropriate.

How to repeat:
./configure

Suggested fix:
Change close to fclose
Check return value from fopen
[18 Jul 2003 19:50] [ name withheld ]
I just discovered that the "quirk" in FreeBSD is in fact a bug, which has been corrected
in the development CVS tree.  Nevertheless, the mysql bug should be fixed as well.
[19 Jul 2003 1:32] Sergei Golubchik
thanks for noticing this. corrected.