Bug 197196 - databases/freetds-devel: fix broken build and correct SIGBUS on tdsdbopen()
Summary: databases/freetds-devel: fix broken build and correct SIGBUS on tdsdbopen()
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Muhammad Moinur Rahman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-30 14:03 UTC by Dave Green
Modified: 2015-02-06 08:24 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (bofh)


Attachments
temporarily suppress _res macro (418 bytes, patch)
2015-01-30 14:03 UTC, Dave Green
no flags Details | Diff
use getenv("HOME") instead of getpwuid_r (234 bytes, patch)
2015-01-30 14:04 UTC, Dave Green
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Green 2015-01-30 14:03:02 UTC
port is currently marked BROKEN as the build fails with:

In file included from threadsafe.c:86:
../../include/freetds/tds.h:149:16: error: bit-field '__res_state' has non-integral type 'TDS_USMALLINT (*())'
        TDS_USMALLINT _res:10;

/usr/include/resolv.h:282:16: note: expanded from macro '_res'
#define _res (*__res_state())

The offending line attempts to define a member of a bitfield named _res within a typedef struct TDS_DATETIMEALL and fails as _res is defined a macro within the included header resolv.h

The attached trivial patch temporarily ignores the macro definition for the definition of TDS_USMALLINT only. #pragma push_macro() is an extension but is supported by both clang and GCC. The patch is crude but succinct and self-documenting.

Additionally both in the freetds and freetds-devel ports calls to tdsdbopen() result in SIGBUS.

#0  0x000000080086b7e1 in tds_read_config_info (tds=0x801c42480, login=0x6477702f6374652f, locale=0x801c20040) at config.c:176
#1  0x000000080082b3f3 in tdsdbopen (login=0x800bfcb7c, server=0x0, msdblib=1) at dblib.c:1219
#2  0x000000080084b532 in dbopen (login=0x800bfcb7c, server=0x0) at dbopen.c:44
#3  0x0000000800bb01e4 in getpwent () from /lib/libc.so.7
#4  0x0000000800baf1b0 in getpwent_r () from /lib/libc.so.7
#5  0x0000000800bc2e2f in nsdispatch () from /lib/libc.so.7
#6  0x0000000800bafc1e in getpwuid_r () from /lib/libc.so.7
#7  0x000000080087ee76 in tds_get_homedir () at threadsafe.c:436
#8  0x000000080086d911 in tds_get_home_file (file=0x80089d3fd ".freetds.conf") at config.c:320
#9  0x000000080086c723 in tds_read_conf_file (login=0x801c231e0, server=0x801c201a8 "192.168.0.1:1234") at config.c:371
#10 0x000000080086b7f2 in tds_read_config_info (tds=0x801c42180, login=0x801c23100, locale=0x801c20040) at config.c:176
#11 0x000000080082b3f3 in tdsdbopen (login=0x801c22058, server=0x401345 "192.168.0.1:1234", msdblib=1) at dblib.c:1219

Although I can't see an obvious flaw with the call to getwpuid_r at threadsafe.c:436 a patch that disables this call and instead obtains the homedir via getenv("HOME") prevents the problem and still allows configuration files to be read from the home directory.
Comment 1 Bugzilla Automation freebsd_committer 2015-01-30 14:03:02 UTC
Auto-assigned to maintainer bofh@freebsd.org
Comment 2 Dave Green 2015-01-30 14:03:52 UTC
Created attachment 152372 [details]
temporarily suppress _res macro
Comment 3 Dave Green 2015-01-30 14:04:40 UTC
Created attachment 152373 [details]
use getenv("HOME") instead of getpwuid_r
Comment 4 commit-hook freebsd_committer 2015-02-06 08:23:39 UTC
A commit references this bug:

Author: bofh
Date: Fri Feb  6 08:22:57 UTC 2015
New revision: 378508
URL: https://svnweb.freebsd.org/changeset/ports/378508

Log:
  databases/freetds-devel: Update version 0.92.812=>0.92.870

  - UnBREAK [1]
  - Correct SIGBUS on tdsdbopen() [1]

  PR:			197196 [1]
  Differential Revision:	https://reviews.freebsd.org/D1773
  Submitted by:		dg@fastmail.co.uk [1]
  Approved by:		marino(mentor)

Changes:
  head/databases/freetds-devel/Makefile
  head/databases/freetds-devel/distinfo
  head/databases/freetds-devel/files/patch-include_freetds_tds.h
  head/databases/freetds-devel/files/patch-src_tds_threadsafe.c
  head/databases/freetds-devel/pkg-plist