Skip to Content.
Sympa Menu

freetds - Re: [freetds] Segmentation fault on dbinit()

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Paul Andrews <andrewsp AT andronics.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Segmentation fault on dbinit()
  • Date: Thu, 25 Oct 2007 17:14:05 +0100

James,
thanks.

I can confirm that
1. dbinit is only called once.
2. fopen causes a segmentation fault

I had been running Suse 10.2 and the code did compile, debug and run
on this machine. When I had repeated issues in getting the code to run,
I sent the entire project over to a colleague who successfully debugged
and ran the program on his 10.2 installation.

I then decided to update to Suse 10.3 (complete format and new
installation).

Problem is still there.

The only difference between my machine and my colleague's is I've
updated the kernel and glibc.

I have glibc 2.6.1-18.3, he has glibc 2.4-31.1

To test fopen, I wrote the following based on tds code:

int main(int argc, char *argv[])
{
FILE *in;
char *s;
char line[256];

in = fopen("/etc/locales.conf", "r");

while (fgets(line, 256, in)) {
s = line;
printf("%s\n", line);
}

return EXIT_SUCCESS;
}


This works fine.

Any clues?

Paul.

-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org]On Behalf Of James K. Lowden
Sent: 25 October 2007 16:33
To: FreeTDS Development Group
Subject: Re: [freetds] Segmentation fault on dbinit()


Paul Andrews wrote:
> I left out a rather crucial piece of information: the code AS IS
> compiles, debugs, and runs fine on another Suse 10.2 machine.

For the record, it's easy for something to be slightly different.

> The line that is failing is
> in = fopen(FREETDS_LOCALESCONFFILE, "+r");
> in the tds_get_locale() function.
>
> The environment variable FREETDS_LOCALESCONFFILE must be NULL (I
> imagine).

#define FREETDS_LOCALECONFFILE FREETDS_SYSCONFDIR TDS_SDIR_SEPARATOR
#"locales.conf"

It's not an environment variable.

> locales.conf is in /etc as is freetds.conf (which is evidently found
> because tsql works).

And FreeTDS tolerates a missing locale.conf. Without one, it uses its
compiled-in defaults.

I would try setting TDSDUMP and looking at the log. It will tell you if
dbinit() is being called more than once. If it is, you then have enough
information to fix your program, including entropy's good advice.

All segmentation faults are bugs, however. If you determine that you are
calling dbinit() more than once, and it's causing a segmentation fault,
please post a message here, and I'll look into it. It should only FAIL,
not crash.

That said, if the program really crashes inside fopen(3), I don't know
what to tell you. It's being passed two compiled-in values, and in any
case it's impossible, or should be, to induce a segmentation fault by
calling fopen(3), no matter what parameters are passed.

In your shoes, I'd be much more inclined to doubt myself than the C
standard library.

HTH.

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

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.10/1092 - Release Date:
25/10/2007 13:14






Archive powered by MHonArc 2.6.24.

Top of Page