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

ThreadSanitizer error on an ebpf-enabled WSL2 kernel #12183

Open
1 of 2 tasks
Timothy-Liuxf opened this issue Oct 19, 2024 · 6 comments
Open
1 of 2 tasks

ThreadSanitizer error on an ebpf-enabled WSL2 kernel #12183

Timothy-Liuxf opened this issue Oct 19, 2024 · 6 comments

Comments

@Timothy-Liuxf
Copy link

Timothy-Liuxf commented Oct 19, 2024

Windows Version

10.0.26100.2033

WSL Version

2.2.4.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

6.6.36.6-microsoft-standard-WSL2+

Distro Version

Ubuntu 24.04

Other Software

GCC 13.2.0

Repro Steps

Compile the WSL2 kernel with an eBPF-enabled configuration:

CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
# [for tc filters]
CONFIG_NET_CLS_BPF=y
# [for tc actions]
CONFIG_NET_ACT_BPF=y
CONFIG_BPF_JIT=y
# [for Linux kernel versions 4.1 through 4.6]
CONFIG_HAVE_BPF_JIT=y
# [for Linux kernel versions 4.7 and later]
CONFIG_HAVE_EBPF_JIT=y
# [for kprobes]
CONFIG_BPF_EVENTS=y
# Need kernel headers through /sys/kernel/kheaders.tar.xz
CONFIG_IKHEADERS=y

and in %USERPROFILE%\.wslconfig:

[wsl2]
memory=16GB
kernel=E:\\vm\\wsl\\kernel\\6.6.36.6-ebpf\\bzImage

And for a C++ program:

// File: hello.cpp
int main() {}

Compile and run with GCC 13.2.0:

$ g++ hello.cpp -fsanitzer=thread
$ ./a.out

Expected Behavior

No output and exit normlly

Actual Behavior

$ g++ hello.cpp -fsanitzer=thread
$ ./a.out
FATAL: ThreadSanitizer: unexpected memory mapping 0x5f901d89d000-0x5f901d89e000

Diagnostic Logs

WslLogs-2024-10-19_14-55-45.zip

Copy link

The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Diagnostic information
.wslconfig found
	Custom kernel found: 'E:\vm\wsl\kernel\6.6.36.6-ebpf\bzImage'
Detected appx version: 2.2.4.0
Found no WSL traces in the logs

@Timothy-Liuxf
Copy link
Author

Copy link

The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.

Diagnostic information
.wslconfig found
	Custom kernel found: 'E:\vm\wsl\kernel\6.6.36.6-ebpf\bzImage'
Detected appx version: 2.2.4.0
Found no WSL traces in the logs

@elsaco
Copy link

elsaco commented Oct 19, 2024

Using wsl-2.3.24 and custom kernel it didn't repro.

Kernel was built with:

elsaco@texas:~/test$ zegrep "CONFIG_BPF|CONFIG_NET_ACT_BPF|CONFIG_NET_CLS_BPF|CONFIG_IKHEADERS" /proc/config.gz
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_BPF_JIT_DEFAULT_ON=y
CONFIG_BPF_UNPRIV_DEFAULT_OFF=y
# CONFIG_BPF_PRELOAD is not set
# CONFIG_BPF_LSM is not set
CONFIG_IKHEADERS=y
# CONFIG_BPFILTER is not set
CONFIG_NET_CLS_BPF=y
CONFIG_NET_ACT_BPF=y
# CONFIG_BPF_STREAM_PARSER is not set
CONFIG_BPF_EVENTS=y
elsaco@texas:~/test1$ uname -r
6.6.36.6-wsl-custom
elsaco@texas:~/test/test1$ g++ hello.cpp -fsanitize=thread
elsaco@texas:~/test/test1$ ./a.out
elsaco@texas:~/test/test1$

And using an example from https://github.com/google/sanitizers/wiki/threadsanitizercppmanual for more output:

elsaco@texas:~/test/test2$ ./a.out
==================
WARNING: ThreadSanitizer: data race (pid=889)
  Read of size 4 at 0x55b8684e001c by thread T2:
    #0 Thread2(void*) <null> (a.out+0x12f1) (BuildId: 4d94419b29cfb783c27ee075fe6e7fd6a26ef25e)

  Previous write of size 4 at 0x55b8684e001c by thread T1:
    #0 Thread1(void*) <null> (a.out+0x12ac) (BuildId: 4d94419b29cfb783c27ee075fe6e7fd6a26ef25e)

  Location is global 'Global' of size 4 at 0x55b8684e001c (a.out+0x401c)

  Thread T2 (tid=892, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5ac1a) (BuildId: 38097064631f7912bd33117a9c83d08b42e15571)
    #1 main <null> (a.out+0x1388) (BuildId: 4d94419b29cfb783c27ee075fe6e7fd6a26ef25e)

  Thread T1 (tid=891, finished) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5ac1a) (BuildId: 38097064631f7912bd33117a9c83d08b42e15571)
    #1 main <null> (a.out+0x1367) (BuildId: 4d94419b29cfb783c27ee075fe6e7fd6a26ef25e)

SUMMARY: ThreadSanitizer: data race (/home/elsaco/test/test2/a.out+0x12f1) (BuildId: 4d94419b29cfb783c27ee075fe6e7fd6a26ef25e) in Thread2(void*)
==================
ThreadSanitizer: reported 1 warnings

@Timothy-Liuxf
Copy link
Author

My configuration:

$ zegrep "CONFIG_BPF|CONFIG_NET_ACT_BPF|CONFIG_NET_CLS_BPF|CONFIG_IKHEADERS" /proc/config.gz
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_BPF_JIT_DEFAULT_ON=y
CONFIG_BPF_UNPRIV_DEFAULT_OFF=y
# CONFIG_BPF_PRELOAD is not set
CONFIG_BPF_LSM=y
CONFIG_IKHEADERS=y
# CONFIG_BPFILTER is not set
CONFIG_NET_CLS_BPF=y
CONFIG_NET_ACT_BPF=y
# CONFIG_BPF_STREAM_PARSER is not set
CONFIG_BPF_EVENTS=y
$ uname -r
6.6.36.6-microsoft-standard-WSL2+
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 13.2.0-23ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-13-uJ7kn6/gcc-13-13.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-uJ7kn6/gcc-13-13.2.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (Ubuntu 13.2.0-23ubuntu4)

@Timothy-Liuxf
Copy link
Author

Timothy-Liuxf commented Oct 25, 2024

It seems that CONFIG_BPF_LSM=y is set in my configuration.

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

No branches or pull requests

2 participants