Hello,
I am not sure if this is the appropriate channel but here we go.
I am trying to port a windows c++ application using winelib and I found an issue while using some c++ STL containers.
Here is a minimal example:
# winelib.dll.so
```c++ #include <windows.h> #include <unordered_map> #include <string>
extern "C" int f1(long z) { std::unordered_map<int, std::string> y; return 10; }
spec file ```c++ 2 stdcall f1(long) ```
# Building winelib.dll.so winemaker --console --dll . winebuild --implib -E winedll.spec -o libwinedll.a winebuild --fake-module --dll -E winedll.spec -o winedll.dll make
cp libwinedll.a winedll.dll.so /usr/local/lib/wine/x86_64-unix cp winedll.dll /home/$USER/.wine/drive_c/windows/system32
win64 app ```c++ #include <iostream>
extern "C"{ int f1(long z); }
int main(){ int ret = f1(2); std::cout << ret << std::endl; } ```
# Building win64 app winemaker . -iwinedll make
# Running wine64 win64app.exe.so
# Output 0110:err:virtual:virtual_setup_exception stack overflow 2128 bytes in thread 0110 addr 0x17008c804 stack 0x207b0 (0x20000-0x21000-0x120000)
If I remove the "std::unordered_map<int, std::string> y" from the custom lib it runs normally.
I suspect that wine uses too much of the stack to construct the object, but it's just a wild guess.
Does anybody know what the issue could be? Is it possible to increase the stack size?
Thanks.
On Sun, Oct 9, 2022 at 12:03 PM Vitor Ramos ramos.v89@gmail.com wrote:
Hello,
I am not sure if this is the appropriate channel but here we go.
The right channel for bugs is to report them at https://bugs.winehq.org/ ...
I am trying to port a windows c++ application using winelib and I found an issue while using some c++ STL containers.
Here is a minimal example:
# winelib.dll.so
#include <windows.h> #include <unordered_map> #include <string> extern "C" int f1(long z) { std::unordered_map<int, std::string> y; return 10; } spec file ```c++ 2 stdcall f1(long)
# Building winelib.dll.so winemaker --console --dll . winebuild --implib -E winedll.spec -o libwinedll.a winebuild --fake-module --dll -E winedll.spec -o winedll.dll make
cp libwinedll.a winedll.dll.so /usr/local/lib/wine/x86_64-unix cp winedll.dll /home/$USER/.wine/drive_c/windows/system32
win64 app
#include <iostream> extern "C"{ int f1(long z); } int main(){ int ret = f1(2); std::cout << ret << std::endl; }
# Building win64 app winemaker . -iwinedll make
# Running wine64 win64app.exe.so
# Output 0110:err:virtual:virtual_setup_exception stack overflow 2128 bytes in thread 0110 addr 0x17008c804 stack 0x207b0 (0x20000-0x21000-0x120000)
I see this error every once in a while and most of the time it doesn't seem to affect the working of the program. Does it affect the working of your program in this particular case?
If I remove the "std::unordered_map<int, std::string> y" from the custom lib it runs normally.
I suspect that wine uses too much of the stack to construct the object, but it's just a wild guess.
Does anybody know what the issue could be? Is it possible to increase the stack size?
Thanks.
Am 12.10.2022 um 09:28 schrieb David Kahurani k.kahurani@gmail.com:
0110:err:virtual:virtual_setup_exception stack overflow 2128 bytes in thread 0110 addr 0x17008c804 stack 0x207b0 (0x20000-0x21000-0x120000)
I see this error every once in a while and most of the time it doesn't seem to affect the working of the program. Does it affect the working of your program in this particular case?
If I remove the "std::unordered_map<int, std::string> y" from the custom lib it runs normally.
I suspect that wine uses too much of the stack to construct the object, but it's just a wild guess.
The most likely cause here is that something causes an invalid memory access, and the exception handler causes an invalid memory access, then another and another until the stack is full.
Try to run your test program in a debugger to catch the first chance exception. My guess is that we have some bug in our unordered_map implementation.
On Wed, Oct 12, 2022 at 10:41 AM Stefan Dösinger stefandoesinger@gmail.com wrote:
Am 12.10.2022 um 09:28 schrieb David Kahurani k.kahurani@gmail.com:
0110:err:virtual:virtual_setup_exception stack overflow 2128 bytes in thread 0110 addr 0x17008c804 stack 0x207b0 (0x20000-0x21000-0x120000)
I see this error every once in a while and most of the time it doesn't seem to affect the working of the program. Does it affect the working of your program in this particular case?
If I remove the "std::unordered_map<int, std::string> y" from the custom lib it runs normally.
I suspect that wine uses too much of the stack to construct the object, but it's just a wild guess.
The most likely cause here is that something causes an invalid memory access, and the exception handler causes an invalid memory access, then another and another until the stack is full.
Try to run your test program in a debugger to catch the first chance exception. My guess is that we have some bug in our unordered_map implementation.
For what it's worth, a program that uses unordered_map without bundling the code in a library/dll seems to run without issues.
I found the issue, it was the msvcrt, compiling with --nomsvcrt it works fine. There is some incompatible ABI call from libstdc++ to msvcrt that causes a segfault in malloc/free. I am not sure if is possible to fix, since it will require to change the calling convection inside libstdc++