dbTalk Databases Forums  

sqlcmd stackdump

comp.databases.informix comp.databases.informix


Discuss sqlcmd stackdump in the comp.databases.informix forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dirk Niemeier
 
Posts: n/a

Default sqlcmd stackdump - 07-08-2010 , 05:28 AM






Hi,
I compiled sqlcmd from JL for Windows XP 32bit.
The following statement dumps while an exception occurs.

D:\Informix_DBImport>sqlcmd -u informix -p mypwd -d test 'select * from
hallo'
hallo

1 [main] sqlcmd 3868 exception::handle: Exception: STATUS_ACCESS_VIOLATION

474 [main] sqlcmd 3868 open_stackdumpfile: Dumping stack trace to
sqlcmd.exe.stackdump

2775 [main] sqlcmd 3868 exception::handle: Exception:
STATUS_ACCESS_VIOLATION
- 747 [main] sqlcmd 3868 exception::handle: Error while dumping state
(probably corrupted stack)

a second call generates the following:

D:\Informix_DBImport>sqlcmd -u informix -p mypwd -d test -e 'select *
from hallo'
hallo

6 [sig] sqlcmd 5484 open_stackdumpfile: Dumping stack trace to
sqlcmd.exe.stackdump

D:\Informix_DBImport>sqlcmd -u informix -p mypwd -d test 'select * from
hallo'
hallo

16 [sig] sqlcmd 5532 open_stackdumpfile: Dumping stack trace to
sqlcmd.exe.stackdump

The table hallo has only one column called hallo.

Here is the core file:
Stack trace:
Frame Function Args
0022C7F8 7C802542 (0000065C, 0000EA60, 000000A4, 0022C8EC)
0022C908 610C2643 (00000000, 7C802600, 7C802542, 00000000)
0022C9E8 610BF2F7 (00000000, 00000000, 00000000, 00000000)
0022CA38 610BF70B (0000159C, 0022CA60, 00000000, 78134C58)
0022CAF8 610BF831 (0000159C, 00000006, 0022CB28, 610BF8D5)
0022CB08 610BF86C (00000006, 0022CE80, 00000000, 00000000)
0022CB28 610BF8D5 (00000000, 0022CB48, 62D03AD9, 00000009)
0022CBB8 610ED58D (00D22138, 0022CBFC, 58585858, 58585858)
0022CC68 004095B6 (00D22138, 00000020, 00000007, 00402689)
0022CD18 004030E5 (00000008, 00D08738, 00D085E8, 00000001)
0022CD98 61006E73 (00000000, 0022CDD4, 61006720, 7FFDE000)
End of stack trace

D:\Informix_DBImport>sqlcmd -h
sqlcmd: SQLCMD Version 86.00 (2008-07-15)
IBM Informix CSDK Version 3.50, IBM Informix-ESQL Version 3.50.TC6
Licenced under GNU General Public Licence Version 2 ......

I think there is a problem im my compilition. Perhaps anybody has an
other compiled Windows version?

TIA
Dirk



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkw1qFkACgkQmy0BUrETEsUMqQCeMJENljOYFr XgcKhJ/aiASEsD
uEkAoN15HeE/bDXv97oTm3NK9272GfaB
=ou64
-----END PGP SIGNATURE-----

Reply With Quote
  #2  
Old   
Dirk Niemeier
 
Posts: n/a

Default Re: sqlcmd stackdump - 07-09-2010 , 06:03 AM






Hi again,
I found the position in the source where the dump is created, but don't
know why this happens.
sqlstmt.ec

static void sql_select(Sqlda *idesc, int stmt_code)
...
count = 0;
while (sqlca.sqlcode == 0)
{
printf("sql_select 5\n");
EXEC SQL FETCH c_statement USING DESCRIPTOR idesc;
printf("sql_select 5.1\n");
if (sqlca.sqlcode != 0)
break;
printf("sql_select 5.2\n");
if (qlimit > 0 && count++ >= qlimit)
{
printf("sql_select 5.3\n");
fflush(ctxt_output());
break;
}
printf("sql_select 6\n");
if (print_record(idesc) != 0)
break;
printf("sql_select 7\n");
}

Output:

D:\Software.tmp\Informix\sqlcmd\sqlcmd-86.00>sqlcmd -u informix -p
m$x1bst -d test
SQL[12]: select * from hallo;
sql_select 0/nsql_select 1/nsql_select 2/nsql_select 3/nsql_select
4/nsql_select 5
sql_select 5.1
sql_select 5.2
sql_select 6
hallo
sql_select 7
sql_select 5
sql_select 5.1
1 [main] sqlcmd 2132 exception::handle: Exception:
STATUS_ACCESS_VIOLATION
593 [main] sqlcmd 2132 open_stackdumpfile: Dumping stack trace to
sqlcmd.exe.stackdump
6042 [main] sqlcmd 2132 exception::handle: Exception:
STATUS_ACCESS_VIOLATION
5295 [main] sqlcmd 2132 exception::handle: Error while dumping state
(probably corrupted stack)

It looks like the EXEC SQL crashes the memory and then the access to the
sqlca.sqlcode is damaged. But why?
Is there any special gcc parameter that will prevent this?

TIA
Dirk



Dirk Niemeier schrieb:
Quote:
Hi,
I compiled sqlcmd from JL for Windows XP 32bit.
The following statement dumps while an exception occurs.

D:\Informix_DBImport>sqlcmd -u informix -p mypwd -d test 'select *
from hallo'
hallo

1 [main] sqlcmd 3868 exception::handle: Exception:
STATUS_ACCESS_VIOLATION

474 [main] sqlcmd 3868 open_stackdumpfile: Dumping stack trace to
sqlcmd.exe.stackdump

2775 [main] sqlcmd 3868 exception::handle: Exception:
STATUS_ACCESS_VIOLATION
- 747 [main] sqlcmd 3868 exception::handle: Error while dumping state
(probably corrupted stack)

a second call generates the following:

D:\Informix_DBImport>sqlcmd -u informix -p mypwd -d test -e 'select *
from hallo'
hallo

6 [sig] sqlcmd 5484 open_stackdumpfile: Dumping stack trace to
sqlcmd.exe.stackdump

D:\Informix_DBImport>sqlcmd -u informix -p mypwd -d test 'select *
from hallo'
hallo

16 [sig] sqlcmd 5532 open_stackdumpfile: Dumping stack trace to
sqlcmd.exe.stackdump

The table hallo has only one column called hallo.

Here is the core file:
Stack trace:
Frame Function Args
0022C7F8 7C802542 (0000065C, 0000EA60, 000000A4, 0022C8EC)
0022C908 610C2643 (00000000, 7C802600, 7C802542, 00000000)
0022C9E8 610BF2F7 (00000000, 00000000, 00000000, 00000000)
0022CA38 610BF70B (0000159C, 0022CA60, 00000000, 78134C58)
0022CAF8 610BF831 (0000159C, 00000006, 0022CB28, 610BF8D5)
0022CB08 610BF86C (00000006, 0022CE80, 00000000, 00000000)
0022CB28 610BF8D5 (00000000, 0022CB48, 62D03AD9, 00000009)
0022CBB8 610ED58D (00D22138, 0022CBFC, 58585858, 58585858)
0022CC68 004095B6 (00D22138, 00000020, 00000007, 00402689)
0022CD18 004030E5 (00000008, 00D08738, 00D085E8, 00000001)
0022CD98 61006E73 (00000000, 0022CDD4, 61006720, 7FFDE000)
End of stack trace

D:\Informix_DBImport>sqlcmd -h
sqlcmd: SQLCMD Version 86.00 (2008-07-15)
IBM Informix CSDK Version 3.50, IBM Informix-ESQL Version 3.50.TC6
Licenced under GNU General Public Licence Version 2 ......

I think there is a problem im my compilition. Perhaps anybody has an
other compiled Windows version?

TIA
Dirk


_______________________________________________
Informix-list mailing list
Informix-list (AT) iiug (DOT) org
http://www.iiug.org/mailman/listinfo/informix-list



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkw3Af8ACgkQmy0BUrETEsWhiQCg5cgkNADw6r Qbw1VepoU43tvk
vCcAoNKqpbai/mOgrhyxcpEp6hBMvWZp
=SeZu
-----END PGP SIGNATURE-----

Reply With Quote
  #3  
Old   
Jonathan Leffler
 
Posts: n/a

Default Re: sqlcmd stackdump - 07-09-2010 , 09:20 AM



On Jul 9, 4:03*am, Dirk Niemeier <dirk.nieme... (AT) stueken (DOT) de> wrote:
Quote:
Hi again,
I found the position in the source where the dump is created, but don't
know why this happens.
sqlstmt.ec

static void * * sql_select(Sqlda *idesc, int stmt_code)
...
* * * * count = 0;
* * * * while (sqlca.sqlcode == 0)
* * * * {
* * printf("sql_select 5\n");
* * * * * * EXEC SQL FETCH c_statement USING DESCRIPTOR idesc;
* * printf("sql_select 5.1\n");
* * * * * * if (sqlca.sqlcode != 0)
* * * * * * * * break;
* * printf("sql_select 5.2\n");
* * * * * * if (qlimit > 0 && count++ >= qlimit)
* * * * * * {
* * printf("sql_select 5.3\n");
* * * * * * * * fflush(ctxt_output());
* * * * * * * * break;
* * * * * * }
* * printf("sql_select 6\n");
* * * * * * if (print_record(idesc) != 0)
* * * * * * * * break;
* * printf("sql_select 7\n");
* * * * }

Output:

D:\Software.tmp\Informix\sqlcmd\sqlcmd-86.00>sqlcmd -u informix -p
m$x1bst -d test
SQL[12]: select * from hallo;
sql_select 0/nsql_select 1/nsql_select 2/nsql_select 3/nsql_select
4/nsql_select 5
sql_select 5.1
sql_select 5.2
sql_select 6
hallo
sql_select 7
sql_select 5
sql_select 5.1
* * * 1 [main] sqlcmd 2132 exception::handle: Exception:
STATUS_ACCESS_VIOLATION
* * 593 [main] sqlcmd 2132 open_stackdumpfile: Dumping stack trace to
sqlcmd.exe.stackdump
* *6042 [main] sqlcmd 2132 exception::handle: Exception:
STATUS_ACCESS_VIOLATION
* *5295 [main] sqlcmd 2132 exception::handle: Error while dumping state
(probably corrupted stack)

It looks like the EXEC SQL crashes the memory and then the access to the
sqlca.sqlcode is damaged. But why?
Is there any special gcc parameter that will prevent this?


Given that the problem occurs where you say, I suspect that there must
be a problem in the setup of the descriptor that the FETCH is using,
most likely some form of memory abuse.

I've not had SQLCMD running on Windows (too lazy) for quite a long
time.

There's one other possibility I can think of - also memory abuse - is
that the 'sqlca' is actually being mapped to a function that returns a
pointer to the sqlca structure (normal in threaded ESQL/C - I don't
know whether Windows ESQL/C uses threaded code automatically), and
that pointer has been corrupted.

I'll try to look sometime - maybe even sometime soon. But since it
involves sorting out the Windows compilation environment on my laptop
(I do have Cygwin up and running), it may take some time.

Reply With Quote
  #4  
Old   
Marco Greco
 
Posts: n/a

Default Re: sqlcmd stackdump - 07-09-2010 , 09:35 AM



Jonathan Leffler wrote:
Quote:
On Jul 9, 4:03 am, Dirk Niemeier <dirk.nieme... (AT) stueken (DOT) de> wrote:
Hi again,
I found the position in the source where the dump is created, but don't
know why this happens.
sqlstmt.ec

static void sql_select(Sqlda *idesc, int stmt_code)
...
count = 0;
while (sqlca.sqlcode == 0)
{
printf("sql_select 5\n");
EXEC SQL FETCH c_statement USING DESCRIPTOR idesc;
printf("sql_select 5.1\n");
if (sqlca.sqlcode != 0)
break;
printf("sql_select 5.2\n");
if (qlimit > 0 && count++ >= qlimit)
{
printf("sql_select 5.3\n");
fflush(ctxt_output());
break;
}
printf("sql_select 6\n");
if (print_record(idesc) != 0)
break;
printf("sql_select 7\n");
}

Output:

D:\Software.tmp\Informix\sqlcmd\sqlcmd-86.00>sqlcmd -u informix -p
m$x1bst -d test
SQL[12]: select * from hallo;
sql_select 0/nsql_select 1/nsql_select 2/nsql_select 3/nsql_select
4/nsql_select 5
sql_select 5.1
sql_select 5.2
sql_select 6
hallo
sql_select 7
sql_select 5
sql_select 5.1
1 [main] sqlcmd 2132 exception::handle: Exception:
STATUS_ACCESS_VIOLATION
593 [main] sqlcmd 2132 open_stackdumpfile: Dumping stack trace to
sqlcmd.exe.stackdump
6042 [main] sqlcmd 2132 exception::handle: Exception:
STATUS_ACCESS_VIOLATION
5295 [main] sqlcmd 2132 exception::handle: Error while dumping state
(probably corrupted stack)

It looks like the EXEC SQL crashes the memory and then the access to the
sqlca.sqlcode is damaged. But why?
Is there any special gcc parameter that will prevent this?



Given that the problem occurs where you say, I suspect that there must
be a problem in the setup of the descriptor that the FETCH is using,
most likely some form of memory abuse.

I've not had SQLCMD running on Windows (too lazy) for quite a long
time.

There's one other possibility I can think of - also memory abuse - is
that the 'sqlca' is actually being mapped to a function that returns a
pointer to the sqlca structure (normal in threaded ESQL/C - I don't
know whether Windows ESQL/C uses threaded code automatically), and
that pointer has been corrupted.

I'll try to look sometime - maybe even sometime soon. But since it
involves sorting out the Windows compilation environment on my laptop
(I do have Cygwin up and running), it may take some time.

If that helps, SQSL segv's in similar circumstances at about the 60th or so
FETCH if the Informix data source is built using the Cygwin compiler in MinGW
mode (building in native mode is a definite no-no, as the two memory
management models are inherently incompatible), however, no such thing happens
if the data source is built with MVS, even if the whole application is
compiled and linked with Cygwin (in whatever mode).
--
Ciao,
Marco
__________________________________________________ ____________________________
Marco Greco /UK /IBM Standard disclaimers apply!

Structured Query Scripting Language http://www.4glworks.com/sqsl.htm
4glworks http://www.4glworks.com
Informix on Linux http://www.4glworks.com/ifmxlinux.htm

Reply With Quote
  #5  
Old   
Mike Aubury
 
Posts: n/a

Default Re: sqlcmd stackdump - 07-09-2010 , 09:45 AM



Just for completeness - the error might *not* be in the reading of
sqlca.sqlcode after the FETCH..

You say :

static void sql_select(Sqlda *idesc, int stmt_code)
....
count = 0;
while (sqlca.sqlcode == 0)
{
printf("sql_select 5\n");
EXEC SQL FETCH c_statement USING DESCRIPTOR idesc;
printf("sql_select 5.1\n");
if (sqlca.sqlcode != 0)
break;
printf("sql_select 5.2\n");
if (qlimit > 0 && count++ >= qlimit)
{
printf("sql_select 5.3\n");
fflush(ctxt_output());
break;
}
printf("sql_select 6\n");
if (print_record(idesc) != 0)
break;
printf("sql_select 7\n");
}


So - if sqlca.sqlcode!=0 - it will break out of the while, after printing the
5.1 - but we can't see any printf's after the while indicating that its done
that...

This might just be a c&p issue - but it might be worth adding something like :
printf("sql_select 5\n");
EXEC SQL FETCH c_statement USING DESCRIPTOR idesc;
printf("sql_select 5.1\n");
printf("sql_select 5.15 - sqlcode now : \n",sqlca.sqlcode);

and see if you get that second printf.








--
Mike Aubury

http://www.aubit.com/
Aubit Computing Ltd is registered in England and Wales, Number: 3112827
Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ

Reply With Quote
  #6  
Old   
Dirk Niemeier
 
Posts: n/a

Default Re: sqlcmd stackdump - 07-19-2010 , 08:23 AM



Mike, you are right!
That's not the place where it dumps. It's the free statement of the
Sqlda stucture. See source snipped down. It's at the end of the
sql_command(..).
I think Marco Greco ist right to that there are problems under Windows
when using MVC libraries (from Client SDK) with GNU-C.

I shoud try to get an MVC compiler. Or any other suggestions?

TIA
Dirk



/* Execute internal or SQL command */
void sql_command(char *str)
{
EXEC SQL BEGIN DECLARE SECTION;
char *cmd; /* SQL statement */
EXEC SQL END DECLARE SECTION;
Sqlda *idesc;
int stmt_code;

cmd = str;

/* This is a one-cycle loop that simplifies error handling */
do
{
/* Compile RDSQL statement */
printf("sql_command 0.0\n");
EXEC SQL PREPARE s_statement FROM :cmd;
printf("sql_command 0.1\n");
if (sqlca.sqlcode < 0)
break;
printf("sql_command 0.2\n");

EXEC SQL DESCRIBE s_statement INTO idesc;
printf("sql_command 0.3\n");
if (sqlca.sqlcode < 0)
break;
printf("sql_command 0.4\n");

stmt_code = sqlca.sqlcode;
printf("sql_command 0.5\n");
if (stmt_code == 0)
{
stmt_code = SQ_SELECT;
printf("sql_command 0\n");
sql_select(idesc, stmt_code);
printf("sql_command 1\n");
}
#ifdef SQLREAD
else if (sqlread_allowed(stmt_code))
sql_execute(stmt_code);
else
cmd_resume(E_CMDNOTALLOWED,
sql_stmttype(stmt_code));
#else
#ifdef SQ_EXECPROC
/* Handle stored procedures which return data as SELECT
statements */
else if (stmt_code == SQ_EXECPROC && idesc->sqld > 0)
{
printf("sql_command 3\n");
sql_select(idesc, stmt_code);
printf("sql_command 4\n");
}
#endif /* SQ_EXECPROC */
else
sql_execute(stmt_code);
#endif /* SQLREAD */
printf("sql_command 5\n");

sqlca.sqlcode = 0;

EXEC SQL FREE s_statement;
printf("sql_command 6\n");
if (sqlca.sqlcode < 0)
break;
printf("sql_command 7\n");

free(idesc); <<< --- here it
dumps!!!!
} while (0);
printf("sql_command 8\n");

if (sqlca.sqlcode < 0)
sql_error();
printf("sql_command 9\n");
}










Mike Aubury schrieb:
Quote:
Just for completeness - the error might *not* be in the reading of
sqlca.sqlcode after the FETCH..

You say :

static void sql_select(Sqlda *idesc, int stmt_code)
...
count = 0;
while (sqlca.sqlcode == 0)
{
printf("sql_select 5\n");
EXEC SQL FETCH c_statement USING DESCRIPTOR idesc;
printf("sql_select 5.1\n");
if (sqlca.sqlcode != 0)
break;
printf("sql_select 5.2\n");
if (qlimit > 0 && count++ >= qlimit)
{
printf("sql_select 5.3\n");
fflush(ctxt_output());
break;
}
printf("sql_select 6\n");
if (print_record(idesc) != 0)
break;
printf("sql_select 7\n");
}


So - if sqlca.sqlcode!=0 - it will break out of the while, after printing the
5.1 - but we can't see any printf's after the while indicating that itsdone
that...

This might just be a c&p issue - but it might be worth adding somethinglike :
printf("sql_select 5\n");
EXEC SQL FETCH c_statement USING DESCRIPTOR idesc;
printf("sql_select 5.1\n");
printf("sql_select 5.15 - sqlcode now : \n",sqlca.sqlcode);

and see if you get that second printf.











-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxEUbwACgkQmy0BUrETEsXpDwCfSuhMemXdqb +24B2Nx9Tp9JFI
DHgAoNtSomApkV52ucYyOhvrp+rM0nIo
=W9U1
-----END PGP SIGNATURE-----

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.