Bug #1062 configure fails under FreeBSD 5 using pthreads [PATCH]
Submitted: 16 Aug 2003 0:33 Modified: 21 Aug 2003 11:14
Reporter: Joel Holveck Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:3.23.57 OS:FreeBSD (FreeBSD 5.1)
Assigned to: Lenz Grimmer CPU Architecture:Any

[16 Aug 2003 0:33] Joel Holveck
Description:
In the file mysql-3.23.57/acinclude.m4, line 626 reads "close(file);".  This
should be fclose(file); since it's opened using fopen.  This apparently passes without incident under normal FreeBSD libc, but causes a segfault with libc_r (the pthreads libc) under FreeBSD 5.1.

Actually, I don't see why the close line is there in the first place, since the exit() call that follows will close all stdio streams, but I'm sure the original author had a reason.

How to repeat:
On a FreeBSD 5.1 system, with ports:
# cd /usr/ports/databases/mysql323-server
# make configure
[A lot of configure output... I'm eliding most of it for brevity, but would be happy to supply the full configure output on request. -joelh]
checking "LinuxThreads"... "Not found"
[... -joelh]
checking "for pthread_create in -libc"... "no"
checking "for pthread_create in -lpthread"... "no"
checking "for pthread_create in -lpthreads"... "no"
checking "for pthread_create in -pthread"... "yes"
[... -joelh]
checking if conversion of longlong to float works... Segmentation fault (core dumped)
no
configure: error: Your compiler cannot convert a longlong value to a float!
If you are using gcc 2.8.# you should upgrade to egcs 1.0.3 or newer and try
again
# more work/mysql-3.23.57/config.log
[Within more, search (/) for typedef long long longlong; to find the relevant bit of code and log.]

Suggested fix:
*** mysql-3.23.57/acinclude.m4.~1~      Sat Aug 16 00:27:20 2003
--- mysql-3.23.57/acinclude.m4  Sat Aug 16 00:27:44 2003
***************
*** 623,629 ****
    FILE *file=fopen("conftestval", "w");
    f = (float) ll;
    fprintf(file,"%g\n",f);
!   close(file);
    exit (0);
  }], ac_cv_conv_longlong_to_float=`cat conftestval`, ac_cv_conv_longlong_to_float=0, ifelse([$2], , , ac_cv_conv_longlong_to_float=$2))])dnl
  if test "$ac_cv_conv_longlong_to_float" = "1" -o "$ac_cv_conv_longlong_to_float" = "yes"
--- 623,629 ----
    FILE *file=fopen("conftestval", "w");
    f = (float) ll;
    fprintf(file,"%g\n",f);
!   fclose(file);
    exit (0);
  }], ac_cv_conv_longlong_to_float=`cat conftestval`, ac_cv_conv_longlong_to_float=0, ifelse([$2], , , ac_cv_conv_longlong_to_float=$2))])dnl
  if test "$ac_cv_conv_longlong_to_float" = "1" -o "$ac_cv_conv_longlong_to_float" = "yes"
[21 Aug 2003 11:14] Lenz Grimmer
Thanks for the patch! It has been applied already and will be part of future
releases.