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

Update 2021-12-27-2151(pull request #53805) and later freeze the game #53825

Closed
Proxima-b opened this issue Dec 28, 2021 · 9 comments · Fixed by #53833
Closed

Update 2021-12-27-2151(pull request #53805) and later freeze the game #53825

Proxima-b opened this issue Dec 28, 2021 · 9 comments · Fixed by #53833
Assignees
Labels
<Crash / Freeze> Fatal bug that results in hangs or crashes. OS: Windows Issues related to Windows operating system (S2 - Confirmed) Bug that's been confirmed to exist

Comments

@Proxima-b
Copy link
Contributor

Proxima-b commented Dec 28, 2021

Describe the bug

Experimental build 2021-12-27-2151(pull request #53805) and all later builds have game freezing problem.

Steps to reproduce

1, Using aforementioned build
2, Open the game
3, Create world with only the provided mods
4, Create character and enter said world.
5, Game freeze.

Expected behavior

A Fix or a revert.

Screenshots

No response

Versions and configuration

experimental build 2021-12-27-2151

Additional context

No response

@BrettDong BrettDong added (S1 - Need confirmation) Report waiting on confirmation of reproducibility OS: Windows Issues related to Windows operating system <Crash / Freeze> Fatal bug that results in hangs or crashes. labels Dec 28, 2021
@Cyenthies
Copy link

Cyenthies commented Dec 28, 2021

Win 10 x64. version 0235. Save is attached, just start walking north, past the alien grass, game will then freeze. Game works fine when reverting to 0903 using the same save.
SlowGoing.Clearin.zip
.

@ArchXII
Copy link

ArchXII commented Dec 28, 2021

I personally have this issue as well on Windows 10 x64. Debug logs state something about 'no such process' when trying to access certain directories (mostly the mods directory, which isn't in the root but I also don't use mods so it's probably fine) but that all gets written before the crash. It's a hard freeze on 'building the world', and nothing else is written to crash or debug.

I noticed this earlier but didn't write up an issue because I didn't feel I had anything to add due to the lack of logs written about it. If there's anything else I can check to help, I'm happy to give that information. I have currently moved back to 0903 and it's working fine.

@JyeGuru
Copy link

JyeGuru commented Dec 28, 2021

Did a quick test while testing something else as well, and can confirm this happens, but for me it's before character select.
Edit: Win10x64 19043.1387

cdda-windows-tiles-x64-2021-12-27-0903 - Works
cdda-windows-tiles-x64-2021-12-27-2151 - Freezes on start
cdda-windows-tiles-x64-msvc-2021-12-27-0903 - Works
cdda-windows-tiles-x64-msvc-2021-12-27-2151 - Works

  • Extract game into fresh directory
  • Start and generate a new world (Next, Next, Ok - all defaults)
  • New Character, Random Character
  • Freezes before loading the character confirmation screen
    image
    image

@BrettDong
Copy link
Member

Probably related to #53103.

@KittyTac
Copy link
Contributor

I was just driving and my game froze. It never did before. I think it's related to this.

@BrettDong BrettDong added (S2 - Confirmed) Bug that's been confirmed to exist and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Dec 28, 2021
@BrettDong
Copy link
Member

BrettDong commented Dec 28, 2021

Freeze reproduced by creating a new character in a new world. Loading an existing save does not cause a freeze.

image

Stuck in a seemingly infinite loop in std::generate_canonical() normal_roll().

@BrettDong
Copy link
Member

image

When randomizing new character height, in normal_roll(double, double) the program gets into an infinite loop between normal_roll+171 and normal_roll+239.

@BrettDong
Copy link
Member

BrettDong commented Dec 28, 2021

I suspect GCC 9.3 generated incorrect assembly code for normal_distribution::operator(). Its source code is in libstdc++-v3/include/bits/random.tcc around line 1800, and this implementation is identical between GCC 9.3 and GCC 11.2:

1794    /**
1795    * Polar method due to Marsaglia.
1796    *
1797    * Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag,
1798    * New York, 1986, Ch. V, Sect. 4.4.
1799    */
1800   template<typename _RealType>
1801     template<typename _UniformRandomNumberGenerator>
1802       typename normal_distribution<_RealType>::result_type
1803       normal_distribution<_RealType>::
1804       operator()(_UniformRandomNumberGenerator& __urng,
1805                  const param_type& __param)
1806       {
1807         result_type __ret;
1808         __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1809           __aurng(__urng);
1810 
1811         if (_M_saved_available)
1812           {
1813             _M_saved_available = false;
1814             __ret = _M_saved;
1815           }
1816         else
1817           {
1818             result_type __x, __y, __r2;
1819             do
1820               {
1821                 __x = result_type(2.0) * __aurng() - 1.0;
1822                 __y = result_type(2.0) * __aurng() - 1.0;
1823                 __r2 = __x * __x + __y * __y;
1824               }
1825             while (__r2 > 1.0 || __r2 == 0.0); // <--- INFINITE LOOP HERE
1826 
1827             const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2);
1828             _M_saved = __x * __mult;
1829             _M_saved_available = true;
1830             __ret = __y * __mult;
1831           }
1832 
1833         __ret = __ret * __param.stddev() + __param.mean();
1834         return __ret;
1835       }
1836 
GCC 9.3 GCC 11.2
gcc-9 gcc-11

Watch for v2_double[0] of the two operand xmm registers.

__r2 > 1.0 corresponds to the comisd xmmA, xmmB instruction. In the program compiled by GCC 11, xmm8 holds a pseudo-random number between 0.0 and 1.0, and the loop exits because xmm8 is less than xmm11 which holds 1.0. But in the program compiled by GCC 9, xmm8 holds 2^126 and xmm2 holds 2^63, and because xmm8 is always greater than xmm2, the program can never escape from this infinite loop.

In the program compiled by GCC 9, xmm2 is supposed to hold constant value 1.0, and xmm8 is supposed to hold the pseudo-random number between 0.0 and 1.0. Before entering std::generate_canonical() the register xmm2 indeed reads 1.0, but inside std::generate_canonical() the register value is overwritten to 2^32.

Reverting to GCC 11.2 solves this infinite loop problem in roll_normal(), but reverting to GCC 11.2 also brings the garbage stack trace problem back.

@Proxima-b Proxima-b changed the title update 2021-12-27-2151(pull request #53805) and later freeze the game Update 2021-12-27-2151(pull request #53805) and later freeze the game Dec 28, 2021
@GoLoT
Copy link
Contributor

GoLoT commented Dec 28, 2021

Does it still fail when forcing the engine to LCG?
using cata_default_random_engine = std::linear_congruential_engine<unsigned int, 16807, 0, 2147483647>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Crash / Freeze> Fatal bug that results in hangs or crashes. OS: Windows Issues related to Windows operating system (S2 - Confirmed) Bug that's been confirmed to exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants