Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consumed catch2 from usersim path #3973

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

agarwalishita
Copy link

Description

Catch2 was getting synced at 2 paths:
external\catch2
external\usersim\external\catch2

So, the former submodule has been deleted as part of this PR
and the source path used is : external\usersim\external\catch2 for creating build file

Copy link
Collaborator

@dthaler dthaler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me other than needing one line deleted.
Thanks for doing this!

.github/dependabot.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@dthaler dthaler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need to delete the original catch2 line from dependabot.yml

dthaler
dthaler previously approved these changes Oct 31, 2024
@agarwalishita
Copy link
Author

@dthaler few tests are failing for this build,
it shows error as Assertion failed: !m_redirectActive && "redirect is already active", file D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\external\Catch2\src\catch2/internal/catch_output_redirect.hpp, line 40

This error is ambiguous for me, is it related catch2 registration failure as the path in catch_wrapper file is not correct? or is it something else? Would appreciate your help.

@dthaler
Copy link
Collaborator

dthaler commented Nov 1, 2024

@dthaler few tests are failing for this build, it shows error as Assertion failed: !m_redirectActive && "redirect is already active", file D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\external\Catch2\src\catch2/internal/catch_output_redirect.hpp, line 40

This error is ambiguous for me, is it related catch2 registration failure as the path in catch_wrapper file is not correct? or is it something else? Would appreciate your help.

I don't know, but it seems to be specific to netebpfext. @Alan-Jowett @shankarseal have you seen this before?

@shpalani
Copy link
Collaborator

shpalani commented Nov 4, 2024

Can you refer to the stack dump here: #3972 (comment)

@agarwalishita
Copy link
Author

Can you refer to the stack dump here: #3972 (comment)

Looking at the stack trace, catch2 is still being searched at the previous path for netebpfext_unit in here : netebpfext_unit!Catch::operator<<+0x5d [D:\a\ebpf-for-windows\ebpf-for-windows\external\Catch2\src\catch2\internal\catch_lazy_expr.cpp @ 20]

so, do I need to update path in catch_wrapper.hpp? as I am not sure from where is the above path picked up

@shpalani
Copy link
Collaborator

shpalani commented Nov 6, 2024

@agarwalishita I looked at the crash dump of netebpf_unit_tests from this PR.
Catch2 is correctly being picked up from usersim\external. Here are my analysis:

D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\external\Catch2\src\catch2\internal\catch_assertion_handler.cpp @ 25

netebpfext_unit!sock_addr_thread_function+0x26d [D:\a\ebpf-for-windows\ebpf-for-windows\tests\netebpfext_unit\netebpfext_unit.cpp @ 558] 
1c 000000e7`b81ffb50 00007ff6`718c03a6     netebpfext_unit!std::invoke<void (__cdecl*)(std::stop_token,_netebpf_ext_helper *,_fwp_classify_parameters *,enum _sock_addr_test_type,unsigned short,unsigned short),std::stop_token,_netebpf_ext_helper *,_fwp_classify_parameters *,enum _sock_addr_test_type,unsigned short,unsigned short>+0xe8 [C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\include\type_traits @ 1714] 
1d 000000e7`b81ffbf0 00007ff8`5e183010     netebpfext_unit!std::thread::_Invoke<std::tuple<void (__cdecl*)(std::stop_token,_netebpf_ext_helper *,_fwp_classify_parameters *,enum _sock_addr_test_type,unsigned short,unsigned short),std::stop_token,_netebpf_ext_helper *,_fwp_classify_parameters *,enum _sock_addr_test_type,unsigned short,unsigned short>,0,1,2,3,4,5,6>+0x126 [C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\include\thread @ 61] 

0:014> k
 # Child-SP          RetAddr               Call Site
00 000000e7`b81f5d88 00007ff8`9259464c     ntdll!ZwWaitForMultipleObjects+0x14 [minkernel\ntdll\daytona\objfre\amd64\usrstubs.asm @ 947] 
01 000000e7`b81f5d90 00007ff8`9259454e     KERNELBASE!WaitForMultipleObjectsEx+0xec [minkernel\kernelbase\synch.c @ 1551] 
02 000000e7`b81f6080 00007ff8`942321e1     KERNELBASE!WaitForMultipleObjects+0xe [minkernel\kernelbase\synch.c @ 1403] 
03 000000e7`b81f60c0 00007ff8`94231dad     kernel32!WerpReportFaultInternal+0x425 [onecore\windows\feedback\core\faultrep\lib\faultrep.cpp @ 997] 
04 000000e7`b81f61e0 00007ff8`94231d1e     kernel32!WerpReportFault+0x81 [onecore\windows\feedback\core\faultrep\lib\faultrep.cpp @ 1308] 
05 000000e7`b81f6220 00007ff8`925e0134     kernel32!BasepReportFault+0x1e [clientcore\base\win32\client\wer.c @ 45] 
06 000000e7`b81f6250 00007ff8`94c88a15     KERNELBASE!UnhandledExceptionFilter+0x344 [minkernel\kernelbase\xcpt.c @ 685] 
07 (Inline Function) --------`--------     ntdll!RtlpThreadExceptionFilter+0x9b [minkernel\ntdll\rtlstrt.c @ 956] 
08 000000e7`b81f6370 00007ff8`94c6f076     ntdll!RtlUserThreadStart$filt$0+0xac [minkernel\ntdll\rtlstrt.c @ 1153] 
09 000000e7`b81f63b0 00007ff8`94c8480f     ntdll!__C_specific_handler+0x96 [minkernel\crts\crtw32\misc\riscchandler.c @ 446] 
0a 000000e7`b81f6420 00007ff8`94c1192e     ntdll!RtlpExecuteHandlerForException+0xf [minkernel\ntos\rtl\amd64\xcptmisc.asm @ 132] 
0b 000000e7`b81f6450 00007ff8`94c2fb01     ntdll!RtlDispatchException+0x26e [minkernel\ntos\rtl\amd64\exdsptch.c @ 653] 
0c 000000e7`b81f6c10 00007ff8`9256f14c     ntdll!RtlRaiseException+0x1f1 [minkernel\ntos\rtl\amd64\raise.c @ 240] 
0d 000000e7`b81f7400 00007ff6`718e0c46     KERNELBASE!RaiseException+0x6c [minkernel\kernelbase\xcpt.c @ 936] 
0e 000000e7`b81f74e0 00007ff8`5e176e31     netebpfext_unit!_wer_report::_terminate_hook+0x26 [D:\a\ebpf-for-windows\ebpf-for-windows\tests\libs\util\wer_report.hpp @ 91] 
0f 000000e7`b81f7510 00007ff8`5e175610     ucrtbased!_VCrtDbgReportW+0x841 [minkernel\crts\ucrt\src\appcrt\misc\dbgrptt.cpp @ 613] 
10 000000e7`b81ff650 00007ff8`5e162fa1     ucrtbased!_CrtDbgReportW+0x60 [minkernel\crts\ucrt\src\appcrt\misc\dbgrpt.cpp @ 278] 
11 000000e7`b81ff6b0 00007ff8`5e163153     ucrtbased!issue_debug_notification+0x31 [minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp @ 25] 
12 000000e7`b81ff700 00007ff8`5e17ae2d     ucrtbased!__acrt_report_runtime_error+0x13 [minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp @ 154] 
13 000000e7`b81ff760 00007ff8`5e180c6f     ucrtbased!abort+0x1d [minkernel\crts\ucrt\src\appcrt\startup\abort.cpp @ 61] 
14 000000e7`b81ff7a0 00007ff8`5e17eba1     ucrtbased!common_assert_to_stderr<wchar_t>+0xbf [minkernel\crts\ucrt\src\appcrt\startup\assert.cpp @ 187] 
15 000000e7`b81ff800 00007ff8`5e1818af     ucrtbased!common_assert<wchar_t>+0x41 [minkernel\crts\ucrt\src\appcrt\startup\assert.cpp @ 415] 
16 000000e7`b81ff840 00007ff6`7196b3ad     ucrtbased!_wassert+0x2f [minkernel\crts\ucrt\src\appcrt\startup\assert.cpp @ 444] 
17 000000e7`b81ff870 00007ff6`7196b19b     netebpfext_unit!Catch::OutputRedirect::activate+0x3d [D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\external\Catch2\src\catch2\internal\catch_output_redirect.hpp @ 40] 
18 000000e7`b81ff8b0 00007ff6`7190e009     netebpfext_unit!Catch::RedirectGuard::~RedirectGuard+0x5b [D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\external\Catch2\src\catch2\internal\catch_output_redirect.cpp @ 310] 
19 000000e7`b81ff8e0 00007ff6`718f9141     netebpfext_unit!Catch::RunContext::notifyAssertionStarted+0x99 [D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\external\Catch2\src\catch2\internal\catch_run_context.cpp @ 317] 
1a 000000e7`b81ff950 00007ff6`718e5c4d     netebpfext_unit!Catch::AssertionHandler::AssertionHandler+0xd1 [D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\external\Catch2\src\catch2\internal\catch_assertion_handler.cpp @ 25] 
1b 000000e7`b81ff9b0 00007ff6`718c6528     netebpfext_unit!sock_addr_thread_function+0x26d [D:\a\ebpf-for-windows\ebpf-for-windows\tests\netebpfext_unit\netebpfext_unit.cpp @ 558] 
1c 000000e7`b81ffb50 00007ff6`718c03a6     netebpfext_unit!std::invoke<void (__cdecl*)(std::stop_token,_netebpf_ext_helper *,_fwp_classify_parameters *,enum _sock_addr_test_type,unsigned short,unsigned short),std::stop_token,_netebpf_ext_helper *,_fwp_classify_parameters *,enum _sock_addr_test_type,unsigned short,unsigned short>+0xe8 [C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\include\type_traits @ 1714] 
1d 000000e7`b81ffbf0 00007ff8`5e183010     netebpfext_unit!std::thread::_Invoke<std::tuple<void (__cdecl*)(std::stop_token,_netebpf_ext_helper *,_fwp_classify_parameters *,enum _sock_addr_test_type,unsigned short,unsigned short),std::stop_token,_netebpf_ext_helper *,_fwp_classify_parameters *,enum _sock_addr_test_type,unsigned short,unsigned short>,0,1,2,3,4,5,6>+0x126 [C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\include\thread @ 61] 
1e 000000e7`b81ffcb0 00007ff8`94224cb0     ucrtbased!thread_start<unsigned int (__cdecl*)(void *),1>+0xb0 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97] 
1f 000000e7`b81ffd10 00007ff8`94c5ecdb     kernel32!BaseThreadInitThunk+0x10 [clientcore\base\win32\client\thread.c @ 75] 
20 000000e7`b81ffd40 00000000`00000000     ntdll!RtlUserThreadStart+0x2b [minkernel\ntdll\rtlstrt.c @ 1152] 
...
0:014> dx Debugger.Sessions[0].Processes[3740].Threads[5724].Stack.Frames[27].SwitchTo();dv /t /v
Debugger.Sessions[0].Processes[3740].Threads[5724].Stack.Frames[27].SwitchTo()
000000e7`b81ffa00 class Catch::AssertionHandler catchAssertionHandler = class Catch::AssertionHandler
000000e7`b81ffb50 class std::stop_token * token = 0x000000e7`b81ffb90
000000e7`b81ffb58 class _netebpf_ext_helper * helper = 0x000000e7`b637e320
000000e7`b81ffb60 struct _fwp_classify_parameters * parameters = 0x000000e7`b637e200
000000e7`b81ffb68 _sock_addr_test_type type = SOCK_ADDR_TEST_TYPE_CONNECT (0n0)
000000e7`b81ffb70 unsigned short start_port = 0x4d2
000000e7`b81ffb78 unsigned short end_port = 0x4d2
000000e7`b81ff9e8 bool fault_injection_enabled = false
000000e7`b81ff9e4 unsigned short port_number = 0xd204
000000e7`b81ff9e0 unsigned int result = 0x1002
0:014> ? 0xd204
Evaluate expression: 53764 = 00000000`0000d204
0:014> ? 0x4d2
Evaluate expression: 1234 = 00000000`000004d2
0:014> ? 0x1002
Evaluate expression: 4098 = 00000000`00001002
0:014> dx -r1 ((netebpfext_unit!_fwp_classify_parameters *)0xe7b637e200)
((netebpfext_unit!_fwp_classify_parameters *)0xe7b637e200)                 : 0xe7b637e200 [Type: _fwp_classify_parameters *]
    [+0x000] family           : 0x0 [Type: unsigned short]
    [+0x004] destination_ipv4_address : 0x1020304 [Type: unsigned int]
    [+0x008] destination_ipv6_address [Type: FWP_BYTE_ARRAY16_]
    [+0x018] destination_port : 0x4d2 [Type: unsigned short]
    [+0x01c] source_ipv4_address : 0x5060708 [Type: unsigned int]
    [+0x020] source_ipv6_address [Type: FWP_BYTE_ARRAY16_]
    [+0x030] source_port      : 0x162e [Type: unsigned short]
    [+0x032] protocol         : 0x6 [Type: unsigned char]
    [+0x034] compartment_id   : 0x1 [Type: unsigned int]
    [+0x038] app_id           [Type: FWP_BYTE_BLOB_]
    [+0x048] interface_luid   : 0x1 [Type: unsigned __int64]
    [+0x050] token_access_information [Type: _TOKEN_ACCESS_INFORMATION]
    [+0x0a8] user_id          [Type: FWP_BYTE_BLOB_]
    [+0x0b8] reauthorization_flag : 0x0 [Type: unsigned int]
0:014> dx -r1 (*((netebpfext_unit!Catch::StringRef *)0xe7b81ffa20))
(*((netebpfext_unit!Catch::StringRef *)0xe7b81ffa20))                 [Type: Catch::StringRef]
    npos             : 0xffffffffffffffff [Type: unsigned __int64]
    [=0x7ff671afbae0] s_empty          : 0x7ff671afbae9 : "" [Type: char *]
    [+0x000] m_start          : 0x7ff671aef990 : "(result == _get_fwp_sock_addr_action(port_number) || fault_injection_enabled)" [Type: char *]
    [+0x008] m_size           : 0x4d [Type: unsigned __int64]

Code in netebpfext_unit.cpp

#include "catch_wrapper.hpp"

sock_addr_thread_function()
{
        FWP_ACTION_TYPE result;  <<<<< uninitialized.
        ...
        switch (type) {
        ...
        case SOCK_ADDR_TEST_TYPE_CONNECT:
        default:
            result = helper->test_cgroup_inet4_connect(parameters);
            break;
        }
        REQUIRE((result == _get_fwp_sock_addr_action(port_number) || fault_injection_enabled));    <<<< Line 558
}
where result is 4098,  to compare with  _get_fwp_sock_addr_action(port_number) return. Failed.

From usersim:
FWP_ACTION_TYPE
fwp_engine_t::test_cgroup_inet4_connect(_In_ fwp_classify_parameters_t* parameters)
{
    ...
    CXPLAT_DEBUG_ASSERT   <<<< Maybe, did we hit any DEBUG ASSERT
   ...
}

Build logs:

111>ClCompile:
         C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\bin\HostX86\x64\CL.exe /c /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\api_common" /I"D:\a\ebpf-for-windows\ebpf-for-windows\include" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\api" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\ebpfnetsh" /I"D:\a\ebpf-for-windows\ebpf-for-windows\tests\libs\util" /I"D:\a\ebpf-for-windows\ebpf-for-windows\tests\libs\common" /I"D:\a\ebpf-for-windows\ebpf-for-windows\x64\Debug\\" /I"D:\a\ebpf-for-windows\ebpf-for-windows\external\ebpf-verifier\src" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\service" /I"D:\a\ebpf-for-windows\ebpf-for-windows\rpc_interface" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\runtime" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\runtime\user" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\shared" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\shared\user" /I"D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\inc" /I"D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\src" /I"D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\cxplat\inc" /I"D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\cxplat\inc\winuser" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\execution_context" /I"D:\a\ebpf-for-windows\ebpf-for-windows\tests\end_to_end" /I"D:\a\ebpf-for-windows\ebpf-for-windows\tests\sample" /I"D:\a\ebpf-for-windows\ebpf-for-windows\tests\sample\ext\inc" /I"D:\a\ebpf-for-windows\ebpf-for-windows\\tests\xdp" /I"D:\a\ebpf-for-windows\ebpf-for-windows\tools\export_program_info" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\thunk" /I"D:\a\ebpf-for-windows\ebpf-for-windows\libs\thunk\mock" /I"D:\a\ebpf-for-windows\ebpf-for-windows\\netebpfext" /I"D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\external\catch2\src" /I"D:\a\ebpf-for-windows\ebpf-for-windows\external\usersim\external\catch2\build\generated-includes" /I"D:\a\ebpf-for-windows\ebpf-for-windows\external\bpftool" /I"D:\a\ebpf-for-windows\ebpf-for-windows\include\user" /I"D:\a\ebpf-for-windows\ebpf-for-windows\\netebpfext\user" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\km" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\km" /I"D:\a\ebpf-for-windows\ebpf-for-windows\external\ebpf-verifier\build\packages\boost\lib\native\include" /I"D:\a\ebpf-for-windows\ebpf-for-windows\x64\Debug\\" /Zi /nologo /W3 /WX /diagnostics:column /sdl /MP /Od /Oi /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /D _AMD64_ /D _WIN32_WINNT=0x0a00 /D _WINDLL /Gm- /EHsc /RTC1 /MDd /GS /guard:cf /Gy /fp:precise /Qspectre /Zc:wchar_t /Zc:forScope /Zc:inline /std:c++20 /permissive- /Fo"x64\Debug\\" /Fd"x64\Debug\vc143.pdb" /external:W3 /Gd /TP /FC /errorReport:queue /ZH:SHA_256 /we4062 netebpfext_unit.cpp netebpf_ext_helper.cpp

@shpalani
Copy link
Collaborator

shpalani commented Nov 6, 2024

Since the test cases were passing in the baseline, I would like you to check the below:
ebpf-for-windows:

  • msvc_tools_version: 14.41.34120
  • clang version 17.0.3
  • msbuild version '17.11.9.46202'

To rule out, can you check the versions of the Catch2 in usersim repo to compare against? (Maybe, type_traits assert can be caused by mismatch of msvc tools version).


Also, netebpfext_unit.cpp has included:
#include "catch_wrapper.hpp"

Hence check the test\libs\util\catch_wrapper.hpp for path and correctness

@agarwalishita
Copy link
Author

Since the test cases were passing in the baseline, I would like you to check the below: ebpf-for-windows:

  • msvc_tools_version: 14.41.34120
  • clang version 17.0.3
  • msbuild version '17.11.9.46202'

To rule out, can you check the versions of the Catch2 in usersim repo to compare against? (Maybe, type_traits assert can be caused by mismatch of msvc tools version).

Also, netebpfext_unit.cpp has included: #include "catch_wrapper.hpp"

Hence check the test\libs\util\catch_wrapper.hpp for path and correctness

@shpalani These have the same versions for me as well
msvc_tools_version: 14.41.34120
clang version 17.0.3
msbuild version '17.11.9.46202'

Regarding catch_wrapper, as previously mentioned, I am unsure how the library is able to fetch the Catch2 path from an external source directly without specifying its path. If I need to make a change here, what path should I use?

@shpalani
Copy link
Collaborator

shpalani commented Nov 8, 2024

Regarding catch_wrapper, as previously mentioned, I am unsure how the library is able to fetch the Catch2 path from an external source directly without specifying its path. If I need to make a change here, what path should I use?

The path seems right in tests/libs/util/test_util.vcxproj. From your PR code, where the path is being included for catch_all.hpp is $(SolutionDir)external\usersim\external\catch2\src;$(SolutionDir)external\usersim\external\catch2\build\generated-includes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants