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

Bug: Crash on Scrolling with Certain Watchlists #173

Closed
dreamsyntax opened this issue Aug 18, 2024 · 1 comment · Fixed by #174
Closed

Bug: Crash on Scrolling with Certain Watchlists #173

dreamsyntax opened this issue Aug 18, 2024 · 1 comment · Fixed by #174
Labels

Comments

@dreamsyntax
Copy link
Collaborator

image

dolphin-memory-engine.exe!Common::formatMemoryToString(const char * memory, Common::MemType type, unsigned __int64 length, Common::MemBase base, bool isUnsigned, bool withBSwap) Line 654 C++

      if (std::isprint(c))

in MemoryCommon.cpp

image

@dreamsyntax
Copy link
Collaborator Author

Reproduce data;
ROM: GUPE8P
Configuration: gamesettings-configuration-GUPE8P.zip
Dolphin Version: 2407-221
SaveState: SaveState-Crashing-DME-GUPE8P.renameto7z.zip
Watchlist: DME-watchlist-scroll-bug.zip

cristian64 added a commit to cristian64/dolphin-memory-engine that referenced this issue Aug 18, 2024
As the documentation states, the caller must check that the input
character in [`std::isprint()`](https://en.cppreference.com/w/cpp/string/byte/isprint) is a valid `unsigned char`:

> Like all other functions from `<cctype>`, the behavior of
> `std::isprint` is undefined if the argument's value is neither
> representable as `unsigned char` nor equal to `EOF`. To use these
> functions safely with plain `char`s (or `signed char`s), the argument
> should first be converted to `unsigned char`:
>
> ```cpp
> bool my_isprint(char ch)
> {
>     return std::isprint(static_cast<unsigned char>(ch));
> }
> ```

The aforementioned undefined behavior manifests as a debug assertion
when compiled with MSVC:

![image](https://github.com/user-attachments/assets/144e3573-f53c-4e89-a0cd-d615caa2749e)

The affected functionality was introduced in aldelaro5#122.

Fixes aldelaro5#173.
cristian64 added a commit to cristian64/dolphin-memory-engine that referenced this issue Aug 18, 2024
As the documentation states, the caller must check that the input
character in [`std::isprint()`](https://en.cppreference.com/w/cpp/string/byte/isprint) is a valid `unsigned char`:

> Like all other functions from `<cctype>`, the behavior of
> `std::isprint` is undefined if the argument's value is neither
> representable as `unsigned char` nor equal to `EOF`. To use these
> functions safely with plain `char`s (or `signed char`s), the argument
> should first be converted to `unsigned char`:
>
> ```cpp
> bool my_isprint(char ch)
> {
>     return std::isprint(static_cast<unsigned char>(ch));
> }
> ```

The aforementioned undefined behavior manifests as a debug assertion
when compiled with MSVC:

![image](https://github.com/user-attachments/assets/144e3573-f53c-4e89-a0cd-d615caa2749e)

The affected functionality was introduced in aldelaro5#122.

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

Successfully merging a pull request may close this issue.

1 participant