https://bugs.winehq.org/show_bug.cgi?id=58054
--- Comment #2 from Christoph christophgil@gmail.com --- Thank you for getting in touch.
I wanted to share some insights regarding the program diann.exe (https://github.com/vdemichev/DiaNN), which previously crashed with a page fault immediately after startup when run under Wine.
At that time, the author kindly granted us access to the source code (which we unfortunately no longer have). Through basic printf debugging, we identified the issue as a std::vector being modified (elements deleted) while being iterated over—a classic case of unsafe concurrent modification.
Once this bug was resolved, DIA-NN ran stably under Wine and was even successfully ported to Linux natively.
Although I’m not a C++ programmer, I do have experience in Java, where such an error would typically result in a runtime exception. The fact that the VC++ environment did not catch this might suggest that this type of issue is a common programming pitfall, potentially contributing to the instability of Windows executables under Wine.
At the time, I was not yet well-versed in Wine internals. Today, I would consider replacing certain DLLs with their native Windows counterparts as a possible workaround.
Suggestions:
1. Quick & Low-Effort Improvement: Implementing modification counters in containers (e.g., vectors, lists) could help detect unsafe changes during iteration. These counters could increment on insertions or deletions, triggering a warning to /dev/stderr if a concurrent modification is detected. This could be accompanied by guidance on resolving the issue, possibly using winetricks or other tools.
2. Longer-Term Enhancement: Making standard containers more tolerant to concurrent modifications would require significantly more effort, but could increase robustness for a broader range of applications.
Please let me know if any of this is helpful or if you'd like me to elaborate further.