PKU-ASAL / SeeWasm

A native symbolic execution engine for WebAssembly
36 stars 4 forks source link

`strstr` function does not perform well #67

Open HNYuuu opened 2 years ago

HNYuuu commented 2 years ago

Describe the bug In Wasm-samples/c_samples.nosync/source/test_c_library.c, we add a strstr function to illustrate the ability of our engine.

However, after several tests, we find that: once the needle is longer than 4 bytes, the strstr would invoke twoway_strstr, and the return value of strstr is always 0.

We find the source code of twoway_strstr, and put it in Wasm-samples/c_samples.nosync/source/twoway_strstr.c, whose result is equivalent to the real execution.

Thus, we guess the reason behind that is:

To Reproduce Directly execute these two samples to see the different:

The twoway_strstr we found:

python3 eunomia_entry -f /Users/ningyuhe/Downloads/test.wasm -s --onlyfunc __original_main --concrete_globals

The problematic strstr:

python3 eunomia_entry -f ./Wasm-samples/c_samples.nosync/wasi/test_c_library.wasm -s --onlyfunc __original_main --concrete_globals

Expected behavior The haystack is TutorialPoint and the needle is Point. Thus, the output should be Point.

HNYuuu commented 2 years ago

I doubted that it may be the compiler's problem. However, the wasmtime can output the correct string.

Thus, we can conclude it is due to some inherent problems in our framework.

HNYuuu commented 2 years ago

Weird output, but I have no time to step in this issue. Leave for other developers.