Skip to Content.
Sympa Menu

freetds - Re: [freetds] I'm having a crashing problem with FreeTDS under OSX

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Daniel Parnell <me AT danielparnell.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] I'm having a crashing problem with FreeTDS under OSX
  • Date: Sat, 7 Mar 2009 12:55:56 +1100

I put some printfs in around the free and it appears to be pointing to a valid date format.
If I just comment out the free it then seems to fail on the next free the code hits (and of course leaks;)
It is almost as if the heap is getting corrupted somehow it freeing up allocated memory is crapping out.

What I might try doing is something like the following

free(malloc(100));

and see what happens

Daniel

On 06/03/2009, at 4:52 PM, James K. Lowden wrote:

Daniel Parnell wrote:
here is the first little bit of the stack trace for the first
crash
I'm seeing.

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000016
0x0010f7fa in free ()
(gdb) bt
#0 0x0010f7fa in free ()
#1 0x02f55c38 in _SQLAllocEnv (phenv=0x812c70) at odbc.c:1353

Bug. Eh. The pointer being freed might not have been allocated, and
isn't zeroed when initialized.

free(ctx->locale->date_fmt);

Locale is allocated by tds_alloc_locale() and initialized by
tds_parse_locale(). Something's a little wrong, because
tds_parse_locale() should find a proper date format string in
locales.conf. In case it doesn't, though, *nothing* initializes the
memory; it's just pointing to random space. A little while later, the
ODBC driver fastidiously frees the tiny string it thinks was allocated,
and you send a message to the list.

I would double-check what's going on with TDSDUMPCONFIG, which should show
a locales.conf being read and the date_fmt being initialized. But this
patch wouldn't do any harm:

RCS file: /cvsroot/freetds/freetds/src/tds/mem.c,v
retrieving revision 1.175.2.2
diff -u -r1.175.2.2 mem.c
--- src/tds/mem.c 5 Nov 2008 14:56:12 -0000 1.175.2.2
+++ src/tds/mem.c 6 Mar 2009 05:49:34 -0000
@@ -656,7 +656,7 @@
{
TDSLOCALE *locale;

- TEST_MALLOC(locale, TDSLOCALE);
+ TEST_CALLOC(locale, TDSLOCALE, 1);
return locale;

Cleanup:

HTH.

--jkl
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds





Archive powered by MHonArc 2.6.24.

Top of Page