1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Hard Crash at end of turn - 100% reproducible

Discussion in 'Bugs and Crashes' started by code99, Jan 28, 2019.

  1. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    14,963
    Gender:
    Male
    Location:
    Western IL. cornfields
    Sorry Raxxo but what Toffer says is correct. And your information or understanding is not. And what Toffer has posted is the same thing an then IBM Virtual Machine programmer told me several years ago. This person now runs ( is the Head of) the IT dept. of a Local County Hospital. Has been working in computer programming, maintenance, and building since 1997.
     
  2. Harrier

    Harrier Chieftain

    Joined:
    Feb 19, 2002
    Messages:
    2,345
    Location:
    UK
    True. The problem was with the programming, at least it was in the 60/70s when I was a programmer. Inexperienced programmers would declare a variable and not assign a value (null, zero or whatever). When the program ran the variable was allocated a part of the RAM. That variable would then contain what ever was in that part of the ram when previously used. Result - program fail or if lucky crash (so you could debug it.). Of course turning the computer on and off (clearing the RAM) would solve this problem, initially only.


    Real-time operating system (RTOS) are an exception to what I said here, but they are not normal OS's, no personal computers would have one of those.

    Memories.

    In the early 1990's - I used to train very experienced programmers how to write RTOS programs for banks , hospitals etc. At the time I worked for an American company that sold those type of machines.
     
  3. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    5,249
    Location:
    Norway
    It's dependent on the programming language used, but what you say there is an important aspect for programmers to be aware of regardless of what language they know and use.

    I have limited experience with programming, but I would think that most of the "modern" programming languages, when declaring a variable without a value, automatically set's the initial value to a default that is appropriate for the variable type in question.
    Java automatically sets defaults.
    Lower level programming languages, like assembler and such, does not do much, if anything, automatically. ^^
    Higher level languages like python does so much automatically for you that it is hard to make major programming mistakes, e.g. it's actually impossible to declare a variable without giving it a value in python.
     
  4. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    24,727
    Gender:
    Male
    Location:
    Las Vegas
    You can get stack overflows in C++ by not properly assigning a value to a variable. Some variables more likely to create a problem than others. Generally a NULL value is a valid default, but sometimes problems can still exist if the variable is unassigned - you can even get OOS errors from it oddly enough.

    Thanks for clarifying some things on that Toffer. I'll admit, I was taught some fundamentals of computer science before Windows was a thing. Wasn't even working with DOS in those classes in High School. Apple 2e. How's that for a platform of initial knowledge huh? So what Harrier said is something I was never fully sure had been 'solved'. You explained it well how and why it was fixed but would still often be a good idea to restart the computer now and then, particularly after crashes. Been habitual ever since.
     
  5. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    4,769
    Location:
    Poland
    I just meant, that restarting computer more than once per day isn't really needed, if you have more than 8 GB of RAM.

    I also said I wasn't sure when it stopped being real problem - I never had problems with other applications if others crashed before.
    Or with memory hungry game when it crashed before.

    Only problem with RAM was that sometimes games used HDD as RAM (virtual memory) - then computer could get laggy when I had 4 GB RAM.
    I don't think Civilization 4 can use virtual memory though.

    Modded 64 bit games can easily make computer lag even if you have 8 or 16 GB of RAM, since they aren't limited in memory consumption practically.
     
    Last edited: Feb 8, 2019
  6. sorcdk

    sorcdk Chieftain

    Joined:
    Jun 26, 2014
    Messages:
    59
    Location:
    Denmark
    T
    As far as I am aware that isn't quite how it works nowadays. Quite a long while ago OSs change to have a layer of abstraction between programs memory use and physical RAM locations, with the OS doing the translation through the page table (I might be mixing the name up). This means that a program can run as if it was the only thing running on the computer (in the memory abstraction, practice is different of cause). When a program is declared more or less dead by the OS it can the free up the memory it has allocated for the program from is memory allocation data structure (which is similar to thee structure behind malloc I C).
    Whether what happens at the physical RAM is up to the OS to decide, but it is fairly common to set it to 0 on allocation (if memory serves me correctly malloc do this, I at least seem to recall someone complaining about performance problems related to this). It can therefore be quite hard to get a program to see a non-zero default value in an unassigned variable, especially on simple programs, since the easiest way would be to have the stack expand back to previously used space.
    I don't see how unassigned variables would directly cause a stack overflow (insufficient room on the stack to contain something), but it it is a pointer or equivalent, then it can easily cause you to attempt to access unassigned memory (or other parts of the program), which the OS/memory system will tend to detect and crash you for.
    Most memory leaks comes in one of two flavours:
    1) [only without garbage collection] When a price of memory is allocated, but never deallocated. This is mostly for things placed on the heap with malloc or new.
    2) When some part of the program will keep growing. This could be things like a log of everything happening (maybe so you could undo something), a cache a paths and so on.

    The problem is most likely in the C++ code, and it could easily be related to synchronisation in multiplayer, where you would need to keep track of a lot of details and whether you are sure that others know them too.
     
  7. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    5,249
    Location:
    Norway
    It still work that way with modern OS's, when a process stops, the OS will make the kernel refresh so that ram locations that were flagged as in-use will lose that flag, meaning that that RAM location is ready to be overwritten by another process.
    I'm not sure how the rest of your response is related to my post that you quoted.
    In that post I was only telling someone who thought it necessary to restart their computer every time C2C CTD, due to concerns about memory not cleaning up after a CTD, that such measures are not necessary.
    Even if one restarts C2C the nanosecond after C2C have CTD'd the new C2C process is not counted as the same process as the previous one that is no longer running and the computer will automatically mark any memory used by the old C2C process as available for other processes even if there is a C2C process running at the time when the kernel refreshes.

    You are in your post complicating my simple answer that was meant for a newbie to understand by mixing in subjects such as what may be stored in the physical RAM location after it has been freed; and the subject of "used-but-available" RAM (also known as reclaimable RAM). Words like page tables, (page file space, and physical page frames mapped to logical pages ^^) and malloc will not help in assuring a regular dude(tte) that a comp. restart after a CTD is unnecessary.
    It's not my intention to offend you here, I'm just worried that you may confuse the individual that my post - that you quoted - was intended for.
     
    Last edited: May 18, 2019 at 3:46 PM
    raxo2222 likes this.
  8. sorcdk

    sorcdk Chieftain

    Joined:
    Jun 26, 2014
    Messages:
    59
    Location:
    Denmark
    I might not have been sufficiencly clear, but my intent was more along the lines of saying that there is more to the story, and my audience wasnt so much the person who had the problem as it was the other modders and programmers active in the thread.
    I wasnt so much trying to point out that the OS doesnt keep track of the memory used, as I was trying to point out that the memory one programs sees behaves as if it was not interfered with by other programs (there are some technical details I will gloss over here, which arent relevant in the RAM model). There is a point to be made about memory fragmentation, but that is mostly relevant if you have many things running in parallel that keep requesting new pieces of memory from the OS, so it shouldnt be a problem for a decent modern computer, unless you are doing a LOT of other stuff on the computer in the mean time.
     
    Toffer90 likes this.

Share This Page