Mail Archives: cygwin/2001/05/02/13:46:08
I've got a small example program that blows up just by
importing a particular function.
If a certain function (DB2 v7.1 'sqlogstt') is imported
from a library (the function is not called), the program
blows up. Otherwise, when commented out, the program works
perfectly.
I'm looking for some debug guidance. I've not built any
cygwin stuff before and the steps I _think_ I should take
are pretty involved.
The assembler really doesn't mean much to me, it could,
but it would take quite a bit of work. 8-)
I figure that to really debug this I've got to do the following:
- Download the newest snapshot (plus source) of gcc plus cygwin
- Make sure it still occurs.
- Rebuild cygwin and this application with debug views.
- Try again, seeing what new information I can get and figure
out a next step.
Any more optimized approach?
I've included a bunch of crap here, with the idea that
it could conceivably help. Sorry its so big.
cygcheck is at the very end.
> gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-4/specs
gcc version 2.95.3-4 (cygwin special)
> gcc -g boom.ok.c -o boom.ok.exe /Program\ files/SQLLIB/lib/db2api.lib
> gcc -g boom.bad.c -o boom.bad.exe /Program\ files/SQLLIB/lib/db2api.lib
> ./boom.bad.exe
0 [main] boom.bad 1676 handle_exceptions: Exception:
STATUS_ACCESS_VIOLATION
6154 [main] boom.bad 1676 stackdump: Dumping stack trace to
boom.bad.exe.stackdump
Segmentation fault (core dumped)
- In GDB, after the SIGSEGV, stack looks like this:
cygwin_crt0
_size_of_stack_reserve_
_size_of_stack_reserve_
_size_of_stack_reserve_
??
Assembly listing of cygwin_crt0 follow:
1 GDB Unable to Read Instructions at 0x61003e1c
2 GDB Unable to Read Instructions at 0x61003ddd
3 GDB Unable to Read Instructions at 0x61003c02
Exception: STATUS_ACCESS_VIOLATION at eip=000040F8
eax=00000000 ebx=00000004 ecx=610881EC edx=00000020 esi=610883E8
edi=00000001
ebp=0240F9FC esp=0240FE98 program=c:\kulack\db2src\test\boom.bad.exe
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame Function Args
0240F9FC 000040F8 (00000000, 00000000, 00000000, 00000000)
0240FEB4 000040F8 (00000001, 1A023684, 0A010008, FFFFFFFE)
0240FF10 61003C02 (00000000, 61089D44, BCF15C38, 000006D4)
0240FF40 61003DDD (00401044, 61089D44, E345B408, 00000003)
0240FF60 61003E1C (00000000, 00000000, 819421B0, 00000005)
0240FF90 004010D3 (00401044, FFFFFFFF, 80430C77, 00000000)
0240FFC0 0040103D (61089D44, 0247E6C4, 7FFDF000, 00000000)
0240FFF0 77E992A6 (00401000, 00000000, 000000C8, 00000100)
End of stack trace
Assembly listings of boom.bad.c and cygwin_crt0 follow,
as well as source for boom.bad.c
Code for boom.bad.c:
==============================================
22 {
- 0x40104a <main+6>: call 0x4010d4 <__main>
23 sqleSetTypeCtx(1); /* <--- POP GOES THE WEASEL */
- 0x40104f <main+11>: add $0xfffffff4,%esp
- 0x401052 <main+14>: push $0x1
- 0x401054 <main+16>: call 0x40107c <sqleSetTypeCtx AT 4>
- 0x401059 <main+21>: add $0xc,%esp
24 return 0;
- 0x40105c <main+24>: xor %eax,%eax
- 0x40105e <main+26>: jmp 0x401060 <main+28>
25 }
- 0x401060 <main+28>: mov %ebp,%esp
- 0x401062 <main+30>: pop %ebp
- 0x401063 <main+31>: ret
- 0x401064 <checkSqlCode>: push %ebp
- 0x401065 <checkSqlCode+1>: mov %esp,%ebp
- 0x401067 <checkSqlCode+3>: sub $0x8,%esp
Code for cygwin_crt0 when boom.bad.c blows up:
==============================================
0x401088 <cygwin_crt0>: push %ebp
- 0x401089 <cygwin_crt0+1>: mov %esp,%ebp
- 0x40108b <cygwin_crt0+3>: sub $0x10,%esp
- 0x40108e <cygwin_crt0+6>: push %esi
- 0x40108f <cygwin_crt0+7>: push %ebx
- 0x401090 <cygwin_crt0+8>: mov 0x8(%ebp),%esi
- 0x401093 <cygwin_crt0+11>: add $0xfffffff8,%esp
- 0x401096 <cygwin_crt0+14>: push $0x0
- 0x401098 <cygwin_crt0+16>: push %esi
- 0x401099 <cygwin_crt0+17>: call 0x4010dc
<_cygwin_crt0_common AT 8>
- 0x40109e <cygwin_crt0+22>: add $0x8,%esp
- 0x4010a1 <cygwin_crt0+25>: test %eax,%eax
- 0x4010a3 <cygwin_crt0+27>: je 0x4010ac <cygwin_crt0+36>
- 0x4010a5 <cygwin_crt0+29>: xor %ebx,%ebx
- 0x4010a7 <cygwin_crt0+31>: jmp 0x4010c8 <cygwin_crt0+64>
- 0x4010a9 <cygwin_crt0+33>: lea 0x0(%esi),%esi
- 0x4010ac <cygwin_crt0+36>: sub $0xb0,%esp
- 0x4010b2 <cygwin_crt0+42>: mov %esp,%ebx
- 0x4010b4 <cygwin_crt0+44>: movl $0x0,(%esp,1)
- 0x4010bb <cygwin_crt0+51>: add $0xfffffff8,%esp
- 0x4010be <cygwin_crt0+54>: push %ebx
- 0x4010bf <cygwin_crt0+55>: push %esi
- 0x4010c0 <cygwin_crt0+56>: call 0x4010dc
<_cygwin_crt0_common AT 8>
- 0x4010c5 <cygwin_crt0+61>: add $0x8,%esp
- 0x4010c8 <cygwin_crt0+64>: mov 0x4040d8,%eax
- 0x4010cd <cygwin_crt0+69>: add $0xfffffff4,%esp
- 0x4010d0 <cygwin_crt0+72>: push %ebx
- 0x4010d1 <cygwin_crt0+73>: call *%eax
- 0x4010d3 <cygwin_crt0+75>: nop
==============================================
boom.bad.c:
/* Beginning of source */
// These definitions come from DB2 sqlsystm.h
typedef long sqlint32;
// These definitions come from DB2 sql.h
#define SQL_API_RC int
#define SQL_API_FN __stdcall
SQL_API_RC SQL_API_FN /* Set Application Context
*/
sqleSetTypeCtx (
sqlint32); /* options
*/
SQL_API_RC SQL_API_FN /* Sqlstate Message Retrieval
*/
sqlogstt (
char * pBuffer, /* buffer for message text
*/
short BufferSize, /* buffer size
*/
short LineWidth, /* line width
*/
char * pSqlstate); /* sqlstate
*/
void checkSqlCode();
int main(int argc, char **argv)
{
sqleSetTypeCtx(1);
return 0;
}
void checkSqlCode() {
sqlogstt(0, 0, 0, 0); // This line commented out in boom.ok.c
}
/* End of source */
==============================================
Code for boom.ok.c (i.e. when sqlogstt is commented out):
22 {
- 0x40104a <main+6>: call 0x4010c0 <__main>
23 sqleSetTypeCtx(1);
- 0x40104f <main+11>: add $0xfffffff4,%esp
- 0x401052 <main+14>: push $0x1
- 0x401054 <main+16>: call 0x40106c <sqleSetTypeCtx AT 4>
- 0x401059 <main+21>: add $0xc,%esp
24 return 0;
- 0x40105c <main+24>: xor %eax,%eax
- 0x40105e <main+26>: jmp 0x401060 <main+28>
25 }
- 0x401060 <main+28>: mov %ebp,%esp
- 0x401062 <main+30>: pop %ebp
- 0x401063 <main+31>: ret
- 0x401064 <checkSqlCode>: push %ebp
- 0x401065 <checkSqlCode+1>: mov %esp,%ebp
==============================================
cygcheck -s -v -r output.
Cygnus Win95/NT Configuration Diagnostics
Current System Time: Wed May 2 11:06:56 2001
WinNT Ver 5.0 build 2195 Service Pack 1
Path: /usr/local/bin
/usr/bin
/bin
/kulack/db2src
/cygdrive/c/Perl/bin/
/WINNT/system32
/WINNT
/WINNT/System32/Wbem
/WINNT/SYSTEM32
/WINNT
/WINNT/SYSTEM32/WBEM
/WINNT/SYSTEM32
/WINNT
/WINNT/SYSTEM32/WBEM
/cygdrive/c/Progra~1/Personal Communications
/cygdrive/c/Notes
/cygdrive/c/Utilities
/cygdrive/c/PROGRA~1/DCE/dcelocal/bin
/cygdrive/c/PROGRA~1/DCE/dcelocal/dcedcf
/cygdrive/c/ObjREXX
/cygdrive/c/ObjREXX/OODIALOG
/cygdrive/c/PROGRA~1/IBM/AFS/Client/Program
/cygdrive/c/PROGRA~1/IBM/AFS/Common
/Program files/SQLLIB/BIN
/Program files/SQLLIB/FUNCTION
/Program files/SQLLIB/SAMPLES/REPL
/Program files/SQLLIB/HELP
/cygdrive/c/PROGRA~1/IBM/IMNNQ
/kulack/bin
/kulack/jdk12/bin
/kulack/vslick/win
/cygdrive/c/andrew/exe
z
/lande/CURRENT/dv2/exe/
z
/lande/CURRENT/dv2/exe/
SysDir: C:\WINNT\System32
WinDir: C:\WINNT
PWD = `/kulack'
USER = `kulack'
MAKE_MODE = `unix'
HOME = `/kulack'
NUMBER_OF_PROCESSORS = `1'
PROMPT = `$P$G'
LOGONSERVER = `\\KULACK'
DEV2000INST = `current'
OS2LIBPATH = `C:\WINNT\system32\os2\dll;'
MDIS_PROFILE = `C:\Program Files\SQLLIB\METADATA\PROFILES'
PERL = `c:/perl/bin/perl'
CMVC_COMPONENT = `tn.xpf'
COMSPEC = `C:\WINNT\system32\cmd.exe'
VWSPATH = `C:\Program Files\SQLLIB'
CMVC_FAMILY = `osxpf'
HEYLOG = `//h/private/heylog'
!C: = `C:\cygwin\bin'
DV2_HOME = `H:'
IMNINSTSRV = `C:\PROGRA~1\IBM\IMNNQ'
SYSTEMDRIVE = `C:'
DEV2000ALIAS = `osxpf'
DB2INSTANCE = `DB2'
HOSTNAME = `KULACK'
INCLUDE = `C:\Program Files\SQLLIB\INCLUDE;C:\Program Files\SQLLIB\LIB;C:
\ObjREXX\API'
PROCESSOR_REVISION = `0806'
DV2_USERSTAGE = `usr'
DB2TEMPDIR = `C:\Program Files\SQLLIB'
HOMEWIN = `c:/kulack'
PATHEXT = `.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH'
DEV2000CRIT = `CURRENT'
COMPUTERNAME = `KULACK'
CLASSPATH = `c:\kulack\src\Simplejava;c:\kulack\src\JRexec;C:
\kulack\AS400Toolbox\jt400Access.zip'
NLSPATH = `C:\PROGRA~1\DCE\dcelocal\nls\msg\%L\%N;C:
\PROGRA~1\DCE\dcelocal\nls\msg\enus437\%N'
WINDIR = `C:\WINNT'
USERPROFILE = `C:\Documents and Settings\Administrator'
PS1 = `$(wd=$(cygpath -u "$(cygpath -w "$(/bin/pwd)")"); echo "
\n\[\033]0;Cygwin Bash - $wd\007\033[27m\]Bash $wd\n> \[\033[0m")'
DV2EXE = `z:/lande/CURRENT/dv2/exe/'
LSERVTBL = `z:\lande\CURRENT\dv2\TBL\LANSERVER.TBL'
LOCPATH = `C:\PROGRA~1\DCE\dcelocal\locale'
PROGRAMFILES = `C:\Program Files'
DSMG_DIR = `C:\WINNT\System32'
!:: = `::\'
BOOKSHELF = `C:\ObjREXX\BOOKS'
DEV2000DIR = `z:\lande\CURRENT\dv2'
MACHTYPE = `i686-pc-cygwin'
PROCESSOR_IDENTIFIER = `x86 Family 6 Model 8 Stepping 6, GenuineIntel'
ATKHOME = `h:\'
LC_ALL = `EN_US'
OS = `Windows_NT'
OLDPWD = `/WINNT/System32'
CMVC_ERASE = `del'
PROCESSOR_ARCHITECTURE = `x86'
TEMP = `/cygdrive/c/Temp'
EDITOR = `c:/kulack/vslick/win/vs.exe'
LANG = `ENUS437'
PROCESSOR_LEVEL = `6'
SYSTEMROOT = `C:\WINNT'
VWS_FOLDER = `IBM DB2'
DCEBIN = `C:\PROGRA~1\DCE\dcelocal\bin'
IMNINST = `help'
PCOMM_ROOT = `C:\Program Files\Personal Communications'
AFSHOME = `h:/'
HOMEDRIVE = `C:'
LIB = `C:\ObjREXX\API;C:\Program Files\SQLLIB\LIB'
ALLUSERSPROFILE = `C:\Documents and Settings\All Users'
DCE_USE_WCHAR_NAMES = `1'
SHLVL = `1'
SOUNDPATH = `C:\WINNT'
APPDATA = `C:\Documents and Settings\Administrator\Application Data'
COMMONPROGRAMFILES = `C:\Program Files\Common Files'
HOMEPATH = `\'
ICCASHOST = `rchaskrm'
USERDOMAIN = `KULACK'
KULCYGHOME = `c:/kulack/kulcygwin'
ICM_FOLDER = `Information Catalog Manager'
USERNAME = `kulack'
SHELL = `/bin/sh'
CMVC_RELEASE = `v5r2m0'
HOSTTYPE = `i686'
CDPATH = `.:/kulack/l'
OSTYPE = `cygwin'
TERM = `cygwin'
DCELOC = `C:\PROGRA~1\DCE'
DEV2000SITEDIR = `z:\lande\CURRENT\dv2'
ICCASLIB = `kulack'
VWS_LOGGING = `C:\Program Files\SQLLIB\LOGGING'
_ = `/usr/bin/cygcheck'
TZ = `CST6CDT5,M4.1.0/2,M10.5.0/2'
HKEY_CURRENT_USER\Software\Cygnus Solutions
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
(default) = `/cygdrive'
cygdrive flags = 0x00000022
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/kulack
(default) = `c:\kulack'
flags = 0x00000002
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/Program files
(default) = `c:\Program files'
flags = 0x00000002
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2\/WINNT
(default) = `c:\WINNT'
flags = 0x00000000
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start
Menu\Programs\Cygnus Solutions
(default) = (unsupported type)
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/
(default) = `C:/cygwin'
flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin
(default) = `C:/cygwin/bin'
flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib
(default) = `C:/cygwin/lib'
flags = 0x0000000a
HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options
c: hd NTFS 19069Mb 45% CP CS UN PA FC C_DRIVE
d: cd N/A N/A
h: net NTFS 70312Mb 0% CP CS PA afshome
j: net AFS 2097151Mb 51% CP CS ?S
y: net NTFS 8789Mb 0% CP CS PA dfsrch
z: net AFS 2097151Mb 51% CP CS ?S
c:\Program files /Program files user binmode
C:\cygwin\bin /usr/bin system binmode
C:\cygwin\lib /usr/lib system binmode
C:\cygwin / system binmode
c:\kulack /kulack user binmode
c:\WINNT /WINNT user textmode
c: /cygdrive/c user binmode,noumount
h: /cygdrive/h user binmode,noumount
j: /cygdrive/j user binmode,noumount
y: /cygdrive/y user binmode,noumount
z: /cygdrive/z user binmode,noumount
Found: C:\cygwin\bin\bash.exe
Found: C:\cygwin\bin\cat.exe
Found: C:\cygwin\bin\cpp.exe
Found: C:\cygwin\bin\find.exe
Found: C:\cygwin\bin\gcc.exe
Found: C:\cygwin\bin\gdb.exe
Found: C:\cygwin\bin\ld.exe
Found: C:\cygwin\bin\ls.exe
Found: C:\cygwin\bin\make.exe
Found: C:\cygwin\bin\sh.exe
56k 2000/12/03 C:\cygwin\bin\cygbz21.0.dll - os=4.0 img=1.0 sys=4.0
"cygbz21.0.dll" v0.0 ts=2000/11/20 17:53
82k 2001/01/21 C:\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0
"cygform5.dll" v0.0 ts=2001/1/21 14:39
18k 2000/10/23 C:\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0
"cyggdbm.dll" v0.0 ts=2000/10/22 21:26
17k 2001/01/07 C:\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0
"cyghistory4.dll" v0.0 ts=2001/1/6 22:34
14k 2000/10/23 C:\cygwin\bin\cygintl.dll - os=4.0 img=1.0 sys=4.0
"cygintl.dll" v0.0 ts=2000/10/23 14:02
81k 2000/12/05 C:\cygwin\bin\cygitcl30.dll - os=4.0 img=1.0 sys=4.0
"cygitcl30.dll" v0.0 ts=2000/11/25 19:43
35k 2000/12/05 C:\cygwin\bin\cygitk30.dll - os=4.0 img=1.0 sys=4.0
"cygitk30.dll" v0.0 ts=2000/11/25 19:43
45k 2000/10/22 C:\cygwin\bin\cygjbig1.dll - os=4.0 img=1.0 sys=4.0
"cygjbig1.dll" v0.0 ts=2000/10/22 18:06
119k 2000/10/23 C:\cygwin\bin\cygjpeg6b.dll - os=4.0 img=1.0 sys=4.0
"cygjpeg6b.dll" v0.0 ts=2000/10/22 19:58
53k 2001/01/21 C:\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0
"cygmenu5.dll" v0.0 ts=2001/1/21 14:39
414k 2001/01/21 C:\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0 sys=4.0
"cygncurses++5.dll" v0.0 ts=2001/1/21 14:40
299k 2001/01/21 C:\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0
"cygncurses5.dll" v0.0 ts=2001/1/21 14:38
34k 2001/01/21 C:\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0
"cygpanel5.dll" v0.0 ts=2001/1/21 14:38
163k 2001/02/03 C:\cygwin\bin\cygpng2.dll - os=4.0 img=1.0 sys=4.0
"cygpng2.dll" v0.0 ts=2001/2/3 15:21
108k 2001/01/07 C:\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0 sys=4.0
"cygreadline4.dll" v0.0 ts=2001/1/6 22:34
390k 2000/12/05 C:\cygwin\bin\cygtcl80.dll - os=4.0 img=1.0 sys=4.0
"cygtcl80.dll" v0.0 ts=2000/11/25 19:39
5k 2000/12/05 C:\cygwin\bin\cygtclpip80.dll - os=4.0 img=1.0 sys=4.0
10k 2000/12/05 C:\cygwin\bin\cygtclreg80.dll - os=4.0 img=1.0 sys=4.0
"cygtclreg80.dll" v0.0 ts=2000/11/25 19:39
243k 2000/10/23 C:\cygwin\bin\cygtiff3.dll - os=4.0 img=1.0 sys=4.0
"cygtiff3.dll" v0.0 ts=2000/10/22 20:14
623k 2000/12/05 C:\cygwin\bin\cygtk80.dll - os=4.0 img=1.0 sys=4.0
"cygtk80.dll" v0.0 ts=2000/11/25 19:43
41k 2000/11/20 C:\cygwin\bin\cygXpm-noX4.dll - os=4.0 img=1.0 sys=4.0
"cygXpm-noX4.dll" v0.0 ts=2000/11/19 20:41
45k 2000/11/20 C:\cygwin\bin\cygXpm-X4.dll - os=4.0 img=1.0 sys=4.0
"cygXpm-X4.dll" v0.0 ts=2000/11/19 20:45
49k 2001/02/03 C:\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0
"cygz.dll" v0.0 ts=2001/2/3 14:35
631k 2001/04/25 C:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
"cygwin1.dll" v0.0 ts=2001/4/24 19:01
Cygwin DLL version info:
dll major: 1003
dll minor: 1
dll epoch: 19
dll bad signal mask: 19005
dll old termios: 5
dll malloc env: 28
api major: 0
api minor: 38
shared data: 3
dll identifier: cygwin1
mount registry: 2
cygnus registry name: Cygnus Solutions
cygwin registry name: Cygwin
program options name: Program Options
cygwin mount registry name: mounts v2
cygdrive flags: cygdrive flags
cygdrive prefix: cygdrive prefix
cygdrive default prefix:
build date: Tue Apr 24 20:01:02 EDT 2001
shared id: cygwin1S3
Use -h to see help about each section
"The stuff we call "software" is not like anything that human society
is used to thinking about. Software is something like a machine, and
something like mathematics, and something like language, and
something like thought, and art, and information...
but software is not in fact any of those other things."
Bruce Sterling - The Hacker Crackdown
Fred A. Kulack - AS/400e Java and Java DB2 access, Jdbc, JTA, etc...
IBM in Rochester, MN (Phone: 507.253.5982 T/L 553-5982)
mailto:kulack AT us DOT ibm DOT com Personal: mailto:kulack AT bresnanlink DOT net
AOL Instant Messenger: Home:FKulack Work:FKulackWrk
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -