3638: Revert "Let's not crash the client and server on dbg_assert" r=def- a=heinrich5991

This reverts commit a6e144e.

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
This commit is contained in:
bors[bot] 2021-12-19 18:45:38 +00:00 committed by GitHub
commit 79e5703e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 16 deletions

View file

@ -114,11 +114,11 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg)
if(!test) if(!test)
{ {
dbg_msg("assert", "%s(%d): %s", filename, line, msg); dbg_msg("assert", "%s(%d): %s", filename, line, msg);
dbg_break_imp(); dbg_break();
} }
} }
void dbg_break_imp() void dbg_break()
{ {
#ifdef __GNUC__ #ifdef __GNUC__
__builtin_trap(); __builtin_trap();

View file

@ -42,16 +42,12 @@ extern "C" {
msg - Message that should be printed if the test fails. msg - Message that should be printed if the test fails.
Remarks: Remarks:
Does nothing in release version Also works in release mode.
See Also: See Also:
<dbg_break> <dbg_break>
*/ */
#ifdef CONF_DEBUG
#define dbg_assert(test, msg) dbg_assert_imp(__FILE__, __LINE__, test, msg) #define dbg_assert(test, msg) dbg_assert_imp(__FILE__, __LINE__, test, msg)
#else
#define dbg_assert(test, msg)
#endif
void dbg_assert_imp(const char *filename, int line, int test, const char *msg); void dbg_assert_imp(const char *filename, int line, int test, const char *msg);
#ifdef __clang_analyzer__ #ifdef __clang_analyzer__
@ -71,17 +67,12 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg);
Breaks into the debugger. Breaks into the debugger.
Remarks: Remarks:
Does nothing in release version Also works in release mode.
See Also: See Also:
<dbg_assert> <dbg_assert>
*/ */
#ifdef CONF_DEBUG void dbg_break();
#define dbg_break() dbg_break_imp()
#else
#define dbg_break()
#endif
void dbg_break_imp();
/* /*
Function: dbg_msg Function: dbg_msg
@ -93,7 +84,7 @@ void dbg_break_imp();
fmt - A printf styled format string. fmt - A printf styled format string.
Remarks: Remarks:
Also works in release version Also works in release mode.
See Also: See Also:
<dbg_assert> <dbg_assert>

View file

@ -101,7 +101,8 @@ static int GetID(int Index)
void CUuidManager::RegisterName(int ID, const char *pName) void CUuidManager::RegisterName(int ID, const char *pName)
{ {
dbg_assert(GetIndex(ID) == m_aNames.size(), "names must be registered with increasing ID"); int Index = GetIndex(ID);
dbg_assert(Index == m_aNames.size(), "names must be registered with increasing ID");
CName Name; CName Name;
Name.m_pName = pName; Name.m_pName = pName;
Name.m_Uuid = CalculateUuid(pName); Name.m_Uuid = CalculateUuid(pName);