Assignment DDLJ
Assignment DDLJ
if (n == 1)
return;
bubbleSort(arr, n+1);
}
2)
It seems the thread enters critical section "RtlpWaitOnCriticalSection".
However in the program "Call3rdPartyCode(lpParam)" we gave the argument as NULL.
So it threw an exception and then there was no exit criteria for critical section.
Call Stack :
0:001> kL
# Child-SP RetAddr Call Site
00 00000047`72eff858 00007ffb`c49580fe ntdll!DbgBreakPoint
01 00000047`72eff860 00007ffb`c28e54e0 ntdll!DbgUiRemoteBreakin+0x4e
02 00000047`72eff890 00007ffb`c488485b KERNEL32!BaseThreadInitThunk+0x10
03 00000047`72eff8c0 00000000`00000000 ntdll!RtlUserThreadStart+0x2b
0:001> ~*kL
===========================================================================
===========================================================================
=
Attached the Application verified and got the below call stack for the issue :
0:000> g
(20.5ca4): C++ EH exception - code e06d7363 (first chance)
=======================================
VERIFIER STOP 0000000000000200: pid 0x20: Thread that is exiting owns a critical section.
0000000000005CA4 : Thread ID of the thread that is exiting while owning a critical section.
00007FF7FAA071A0 : Critical section address. Run !cs -s <address> to get more information.
000001F4C924CFD0 : Critical section debug information address.
000001F4C26F0160 : Critical section initialization stack trace. Run dps <address> to dump the stack
trace.
=======================================
This verifier stop is continuable.
After debugging it use `go' to continue.
=======================================
The above clearly highlights the point "Thread that is exiting owns a critical section" where it says that
the thread is trying to exit without leaving the critical section.
3) The code is basically trying to fetch the mapped memory and write it to the location specified
4) It loads the DLL into the memory of the current process, but does not import functions defined.
Function calls are resolved by the linker at compile time while LoadLibrary is called at runtime of the
code
5) Application runs fine with strings upto size of 10, after that it crashes
6)
This is reserving addresses using MEM_RESERVE , and then continously allocating the reserved pages
using MEM_COMMIT.
The code commit another page. Increment the page count, and advance lpNxtPage to the next page.
Reserve pages in the virtual address space of the process.
dump query
1)
2)
EXCEPTION_CODE_STR: 80000003
3)
7! Or 5040
And the operation being performed is a n! factorial operation. You are saving the pointer to the stack
and then returning the address back to the called function, so if the variable is say y, you are doing y+4,
the calling function
4)
An exception is a known type of error. An unhandled exception occurs when the application
code does not properly handle exceptions.
2. Why is the program failing with “System.AccessViolationException”?
Ans. An access violation that occurs in unsafe managed code can be expressed as either a
NullReferenceException exception or an AccessViolationException exception, depending on the
platform
3. Please debug the program and see if you can identify the root cause of the issue. State the
root cause.
Make sure that the memory that you are attempting to access has been allocated. An
AccessViolationException exception is always thrown by an attempt to access protected memory
-- that is, to access memory that is not allocated or that is not owned by a process.
Make sure that the memory that you are attempting to access has not been corrupted. If several
read or write operations have occurred through bad pointers, memory may be corrupted. This
typically occurs when reading or writing to addresses outside of a predefined buffer.
4. What is the underlying function/API being called that has raised the exception?
errhandlingapi.h (EXCEPTION_ACCESS_VIOLATION)
5) Yes the program has memory leaks, the counter selected is the private bytes, the difference between
the average and maximum gives the approx. memory leak. If the counter selected is processor time,
then the values indicate the duration. You can also use, TheMemory/Committed Bytes counter which
raises if there is a memory leak
6) 1. Is there a deadlock?
>> No there are no deadlocks seen.
0:007> !locks
0:009> ~0kb
# RetAddr : Args to Child : Call Site
00 00007ffb`c1ddf9f0 : 00000000`00fd5290 00000000`00000050 00000000`00fd52d0
00007ffb`b5025361 : ntdll!ZwWaitForMultipleObjects+0x14
[minkernel\ntdll\daytona\objfre\amd64\usrstubs.asm @ 947]
01 00007ffb`b50ea0c7 : ffffffff`fffffffe 00000000`00000000 00000000`00cfecc8
00000000`00000000 : KERNELBASE!WaitForMultipleObjectsEx+0xf0 [minkernel\kernelbase\synch.c
@ 1551]
02 00007ffb`b50e9f50 : 00000000`00000000 00000000`00000001 00000000`00f83040
00000000`ffffffff : clr!WaitForMultipleObjectsEx_SO_TOLERANT+0x62
[f:\dd\ndp\clr\src\vm\threads.cpp @ 4302]
03 (Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : clr!
Thread::DoAppropriateAptStateWait+0x36 [f:\dd\ndp\clr\src\vm\threads.cpp @ 4336]
04 00007ffb`b50e9cdd : 00000000`00f83040 00000000`00000001 00000000`00000001
00000000`00000000 : clr!Thread::DoAppropriateWaitWorker+0x205
[f:\dd\ndp\clr\src\vm\threads.cpp @ 4476]
05 00007ffb`b511a91d : 00000000`00fd6ff8 00007ffb`00000001 00000000`00f83040
00000000`00fd7010 : clr!Thread::DoAppropriateWait+0x7d [f:\dd\ndp\clr\src\vm\threads.cpp @
4143]
06 00007ffb`b50ea466 : 00000000`00cfefa0 00000000`00000000 00000000`00f83040
00007ffb`b5025077 : clr!CLREventBase::WaitEx+0xb6 [f:\dd\ndp\clr\src\vm\synch.cpp @ 850]
07 00007ffb`b50ea337 : 00000000`00fd6ff8 00000000`02d66918 00000000`02d66b70
00000000`02d62d80 : clr!AwareLock::EnterEpilogHelper+0x104 [f:\dd\ndp\clr\src\vm\syncblk.cpp
@ 3118]
08 00007ffb`b5206682 : 00000000`00f83040 00007ffb`b50226d0 00000000`00000000
00000000`00fd6ff8 : clr!AwareLock::EnterEpilog+0x62 [f:\dd\ndp\clr\src\vm\syncblk.cpp @ 3063]
09 (Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : clr!
SyncBlock::EnterMonitor+0x8 [f:\dd\ndp\clr\src\vm\syncblk.h @ 776]
0a (Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : clr!
ObjHeader::EnterObjMonitor+0xd [f:\dd\ndp\clr\src\vm\syncblk.cpp @ 1901]
0b (Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : clr!
Object::EnterObjMonitor+0x16 [f:\dd\ndp\clr\src\vm\object.h @ 484]
0c 00007ffb`55ae0a18 : 00000000`00cff0c8 00000000`00cfef88 00000000`00cff098
00000000`00cfef98 : clr!JITutil_MonEnterWorker+0x132 [f:\dd\ndp\clr\src\vm\jithelpers.cpp @
4799]
0d 00007ffb`b5026923 : 00007ffb`b5027070 00007ffb`559d4148 00000000`00000000
00000000`00000000 : Test_a_Lock!Test.Program.Main()+0xe8*** WARNING: Unable to verify
checksum for C:\Users\dideka\OneDrive - Microsoft\Desktop\TDFP
Assesment\Set1\Question6\Test_a_Lock.exe
Compose