Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » GDB says: Program received signal SIGTRAP in ntdll.dll

This thread is locked; no one can reply to it. rss feed Print
GDB says: Program received signal SIGTRAP in ntdll.dll
Niunio
Member #1,975
March 2002
avatar

Folowing with this: I've learned how to use gdb and I think I've found where the error is.

There is the code line:

1 ...
2 /* In the header file */
3 typedef double BAS_NUMBER;
4 ...
5 
6 /* Somewhere in the initialization */
7 basDataStackSize = 512;
8 ...
9 
10 /* In the function */
11 struct _PILA_DATOS_ *Resultado = NULL;
12 
13 if ((Resultado = (struct _PILA_DATOS_*)malloc(sizeof(struct _PILA_DATOS_)))
14 != NULL)
15 {
16 Resultado->Dato = NULL; Resultado->Tipo = NULL;
17 if ((Resultado->Dato = (BAS_NUMBER*)malloc (
18 sizeof(BAS_NUMBER) * basDataStackSize)) != NULL)
19 {
20 ...

And this is what gdb says:

139 struct _PILA_DATOS_ *Resultado = NULL;
2(gdb) n
341 if ((Resultado = (struct _PILA_DATOS_*)malloc(sizeof(struct _PILA_DATOS_)))
4(gdb)
544 Resultado->Dato = NULL; Resultado->Tipo = NULL;
6(gdb) p basDataStackSize
7$15 = 512
8(gdb) n
945 if ((Resultado->Dato = (BAS_NUMBER*)malloc (
10(gdb) n
11warning: HEAP[basrun.exe]:
12warning: HEAP: Free Heap block 3d57f8 modified at 3d580c after it was freed
13 
14 
15Program received signal SIGTRAP, Trace/breakpoint trap.
160x7c911231 in ntdll!DbgUiConnectToDbg () from ntdll.dll
17(gdb) p Resultado->Dato
18No symbol "Resultado" in current context.
19(gdb) n
20Single stepping until exit from function ntdll!DbgUiConnectToDbg,
21which has no line number information.
220x7c97c943 in ntdll!RtlpNtMakeTemporaryKey () from ntdll.dll
23(gdb) n
24Single stepping until exit from function ntdll!RtlpNtMakeTemporaryKey,
25which has no line number information.
260x7c959a2e in ntdll!RtlInsertElementGenericTableAvl () from ntdll.dll
27(gdb) n
28Single stepping until exit from function ntdll!RtlInsertElementGenericTableAvl,
29 
30which has no line number information.
310x7c921e8f in ntdll!RtlInitializeHandleTable () from ntdll.dll
32(gdb) n
33Single stepping until exit from function ntdll!RtlInitializeHandleTable,
34which has no line number information.
350x7c920c31 in wcsncpy () from ntdll.dll
36(gdb) n
37Single stepping until exit from function wcsncpy,
38which has no line number information.
390x7c928251 in ntdll!RtlRealPredecessor () from ntdll.dll
40(gdb) n
41Single stepping until exit from function ntdll!RtlRealPredecessor,
42which has no line number information.
430x7c921b54 in ntdll!RtlInitializeHandleTable () from ntdll.dll
44(gdb) n
45Single stepping until exit from function ntdll!RtlInitializeHandleTable,
46which has no line number information.
470x7c94c087 in ntdll!RtlInsertElementGenericTableAvl () from ntdll.dll
48(gdb) n
49Single stepping until exit from function ntdll!RtlInsertElementGenericTableAvl,
50 
51which has no line number information.
520x7c9130f5 in ntdll!RtlFindCharInUnicodeString () from ntdll.dll
53(gdb) n
54Single stepping until exit from function ntdll!RtlFindCharInUnicodeString,
55which has no line number information.
560x7c94c0a0 in ntdll!RtlInsertElementGenericTableAvl () from ntdll.dll
57(gdb) n
58Single stepping until exit from function ntdll!RtlInsertElementGenericTableAvl,
59 
60which has no line number information.
610x7c921bba in ntdll!RtlInitializeHandleTable () from ntdll.dll
62(gdb) n
63Single stepping until exit from function ntdll!RtlInitializeHandleTable,
64which has no line number information.
650x7c920c86 in wcsncpy () from ntdll.dll
66(gdb) n
67Single stepping until exit from function wcsncpy,
68which has no line number information.
690x7c921bdc in ntdll!RtlInitializeHandleTable () from ntdll.dll
70(gdb) n
71Single stepping until exit from function ntdll!RtlInitializeHandleTable,
72which has no line number information.
730x7c920bcc in wcsncpy () from ntdll.dll
74(gdb) n
75Single stepping until exit from function wcsncpy,
76which has no line number information.
770x7c921bff in ntdll!RtlInitializeHandleTable () from ntdll.dll
78(gdb) c <<< I was boring so I decided to continue.
79Continuing.
80 
81Uso:
82 basrun <archivo.prg>
83 
84warning: HEAP[basrun.exe]:
85warning: Heap block at 003D24A8 modified at 003D2539 past requested size of 89
86 
87 
88Program received signal SIGTRAP, Trace/breakpoint trap.
890x7c911231 in ntdll!DbgUiConnectToDbg () from ntdll.dll
90(gdb) c
91Continuing.
92warning: HEAP[basrun.exe]:
93warning: Invalid Address specified to RtlFreeHeap( 003D0000, 003D24B0 )
94 
95 
96Program received signal SIGTRAP, Trace/breakpoint trap.
970x7c911231 in ntdll!DbgUiConnectToDbg () from ntdll.dll
98(gdb) c
99Continuing.
100warning: HEAP[basrun.exe]:
101warning: Heap block at 003D52E0 modified at 003D57E8 past requested size of 500
102 
103 
104Program received signal SIGTRAP, Trace/breakpoint trap.
1050x7c911231 in ntdll!DbgUiConnectToDbg () from ntdll.dll
106(gdb) c
107Continuing.
108warning: HEAP[basrun.exe]:
109warning: Invalid Address specified to RtlFreeHeap( 003D0000, 003D52E8 )
110 
111 
112Program received signal SIGTRAP, Trace/breakpoint trap.
1130x7c911231 in ntdll!DbgUiConnectToDbg () from ntdll.dll
114(gdb) c
115Continuing.
116 
117Program exited with code 01.
118(gdb)

What's happening? ???

-----------------
Current projects: Allegro.pas | MinGRo

CGamesPlay
Member #2,559
July 2002
avatar

I think this is a delayed error. I think you free something and then modify it later, and the system catches it next time it does a malloc. In conclusion, make sure you set variables to NULL after you delete them, and try it out.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Niunio
Member #1,975
March 2002
avatar

I don't think so. Anyway I've checked all "free" calls I do in all modules and I set all variables to NULL after delete them and also before create them (malloc) and I have same the error.

-----------------
Current projects: Allegro.pas | MinGRo

ReyBrujo
Moderator
January 2001
avatar

Unluckily CGP is right. You have a buffer overrun somewhere in your code. Your best chance is beginning to comment code until you have your program running, and then adding code until it breaks again.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Niunio
Member #1,975
March 2002
avatar

Find it. Oh, man! That was the most stupid error I've done ever: I just put "Cnt<=basNumLabels" instead of "Cnt<basNumLabels" in a for loop :-[. Now it runs.

But I can't understand why it fails in Windows but run perfect in GNU/Linux.

Anyway, thanks: you make me think and check each bit of the program. I thought I never find it. Can't send cookies, sorry :-[ but I'll thank you in the "readme" file of the final release :)

-----------------
Current projects: Allegro.pas | MinGRo

CGamesPlay
Member #2,559
July 2002
avatar

The reason is that MSVCRT's debugging library does heap checking, and GNU/Linux's glibc doesn't (well, maybe the debugging version does, but I doubt you were using it). Valgrind would have found this error, though.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

ReyBrujo
Moderator
January 2001
avatar

It is not on by default, there must be a switch to turn it on.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Go to: