psStat checks to help trackdown corrupted pointers #1903
Comments
Crymson uploaded file |
cybersphinx commented Well, the patch includes some reindentation, if that's needed it should be separated from code changes. And in some places you use tabs to align things (which breaks with anything except your tab setting), those should be spaces. All those places where you add compIndex look like they could be put into a function. Also, it would be nice to have a patch in the ticket with the problem it addresses. For the problem itself, I guess your patch works around it, though somewhere the template list gets corrupted, which might lead to other problems later... |
cybersphinx commented Hm, actually trying to compile I had to remove the assert in scriptfuncs.c:9016 and the change to sstrcpy, since those lead to warnings. Also, the game saves, but the newly created template isn't there. Though I guess that narrows things down a bit. |
cybersphinx commented Looks like only loading the last saved template fails in game.c:9185, though I'm not sure why we'd want to output SDWORD psSaveTemplate->asParts[i] as a string there... |
Zarel commented The compIndex stuff should definitely be going into a function.
or something like that. |
Crymson commented Replying to Warzone2100/old-trac-import#1903 (comment:4):
That will not help find the problem, which is the main reason for doing it the way I did it. For example, let us say it is wrapped in a function, and we hit it. On debug builds, that is OK, since we can check the stack and see where we are coming from. On release builds, then we have no clue, and just get the assert message from the wrapped function, and not the routine where the problem occurred. In other words, it adds another hidden layer if you use a function instead of the way it currently is in the patch. Cybersphinx, what warning did sstrcpy() cause? |
Zarel commented Replying to Warzone2100/old-trac-import#1903 (comment:5):
In other words, no, it doesn't. |
cybersphinx commented Replying to Warzone2100/old-trac-import#1903 (comment:5):
Could use a macro then.
../../src/game.c:11613: error: negative width in bit-field ‘’ Don't ask me what that means, I just looked at the line, saw that it was one you changed, and changed it back. |
Crymson commented Replying to Warzone2100/old-trac-import#1903 (comment:6):
O_o
O_o
Dude, if you don't want to use the patch, then fine, I was only trying to help. In the future, it might help you to brush up on how preprocessors work, since it is painfully obvious that you haven't used them before. Cybersphinx, that is a odd error message, what compiler are you using? There are also some posts about patches in the forums that you guys didn't apply for various reasons, so it seems that your wiki needs to be updated to make it more clear. It would save a lot of time. |
Zarel commented Replying to Warzone2100/old-trac-import#1903 (comment:8):
Oh! I see what you mean; you're referring to the function name in the debug log. Yeah, you're right, an inline function would interfere with that. We could still use a
I don't know how suggesting improvements to your patch in any way implies I don't want it to be committed.
The reasons you've stated are "facepalm" and "O_o". It's a good thing I managed to figure out that you were talking about the error log; next time, English would be preferable for communication.
Psh, I'm not that petty. |
cybersphinx uploaded file Version without pure whitespace changes, v2. |
cybersphinx commented Compiler is gcc 4.4.4 on Linux. For the ASSERT_OR_RETURN in src/scriptfuncs.c:9016, I guess this was supposed to use psStruct instead of psDroid? The one above that looks also strange. Why do you compare some droid stats to numStructureStats? Also, you don't need to put the asserted condition into the text, it is printed automatically (or is that different on Windows?). |
cybersphinx uploaded file Possibly correct. The asserts messages could still be shortened. |
Buginator commented Slight updates, also made it a bit more merge friendly for 2.3, though, that doesn't have to be there, it will just save time in the future. |
Buginator uploaded file |
Buginator uploaded file |
Buginator changed status from |
Buginator set resolution to |
Buginator commented (In [11061]) Add bounds checking to psStats to prevent bad pointers. Closes #1903 |
Buginator commented (In [11062]) Add bounds checking to psStats to prevent bad pointers. Closes #1903 |
Buginator commented (In [11063]) Add bounds checking to psStats to prevent bad pointers. Closes #1903 |
Git SVN Gateway <gateway@...> commented (In Warzone2100/warzone2100@abd4738) Add bounds checking to psStats to prevent bad pointers. Closes #1903 git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@11061 4a71c877-e1ca-e34f-864e-861f7616d084 |
Git SVN Gateway <gateway@...> commented In Warzone2100/warzone2100@abd4738:
|
1 similar comment
Git SVN Gateway <gateway@...> commented In Warzone2100/warzone2100@abd4738:
|
resolution_fixed
type_patch (an actual patch, not a request for one)
| by CrymsonHope I followed the rules correctly for the patch.
I added code to assert when bad pointers would have been made, and fixed a few other asserts to return instead of happily continuing on, as if the pointer wasn't bad.
see ticket 1900 for how it will help that guy out.
Issue migrated from trac:1903 at 2022-04-15 22:00:45 -0700
The text was updated successfully, but these errors were encountered: