Reputation: 11
I have a program running on Windows cmd and when the program throws an error it keeps waiting for user input to either ignore/continue or cancel, but i have this batch file wich restarts the program automatically on error but since it keeps waiting for user input i have to go there and press a button
:unturned
echo (%time%) Unturned started.
cd masterserver
cd VisualStudio
cd Debug
masterserver.exe
@echo All done!
@echo Masterserver listening on port: 23466
echo (%time%) WARNING: Unturned closed or crashed, restarting. >>c:\crashlog.txt
ping 1.1.1.1 -n 1 -w 10000 >nul
goto unturned
How to make it ignore the error and continue automatically?
Here is an image of the prompt:
Upvotes: 1
Views: 2901
Reputation: 11
Updating in case someone has this problem: I compiled it in Release mode just like Remy said and the problem has gone away completely, the application now runs properly without any errors.
Upvotes: 0
Reputation: 598309
That popup message is displayed when an assertion failure occurs in masterserver.exe
. The failure indicates a code bug, as it is testing a condition at compile-time that is expected to always be true at run-time, but the condition was actually false instead.
In this case, the error happened in CCRakNetUDT::OnAck()
in ccraknetudt.cpp
on line 528. That line is calling RakAssert(rtt < 10000000);
, where rtt
is an input parameter to OnAck()
. The assertion is that the value of rtt
should always be less than 10000000
, but it was actually not.
void CCRakNetUDT::OnAck(CCTimeType curTime, CCTimeType rtt, bool hasBAndAS, BytesPerMicrosecond _B, BytesPerMicrosecond _AS, double totalUserDataBytesAcked, bool isContinuousSend, DatagramSequenceNumberType sequenceNumber )
{
#if CC_TIME_TYPE_BYTES==4
RakAssert(rtt < 10000);
#else
RakAssert(rtt < 10000000); // <-- line 528
#endif
When you compile a debug build of masterserver.exe
for platforms other than Xbox, RakAssert()
maps to assert()
, otherwise it is a no-op:
RakAssert.h
#include <assert.h>
#include "RakNetDefines.h"
RakNetDefines.h
#ifndef RakAssert
#if defined(_XBOX) || defined(X360)
#else
#if defined(_DEBUG)
#define RakAssert(x) assert(x);
#else
#define RakAssert(x)
#endif
#endif
#endif
Per the assert()
documentation:
Evaluates an expression and, when the result is false, prints a diagnostic message and aborts the program.
...
The assert macro is typically used to identify logic errors during program development. Use it to stop program execution when unexpected conditions occur by implementing the expression argument to evaluate to false only when the program is operating incorrectly. Assertion checks can be turned off at compile time by defining the macro
NDEBUG
. You can turn off the assert macro without modifying your source files by using a/DNDEBUG
command-line option. You can turn off the assert macro in your source code by using a#define NDEBUG
directive before<assert.h>
is included.The assert macro prints a diagnostic message when expression evaluates to false (0) and calls
abort
to terminate program execution. No action is taken if expression is true (nonzero). The diagnostic message includes the failed expression, the name of the source file and line number where the assertion failed....
The destination of the diagnostic message depends on the type of application that called the routine. Console applications always receive the message through
stderr
. In a Windows-based application,assert
calls the WindowsMessageBox
function to create a message box to display the message along with anOK
button. When the user clicksOK
, the program aborts immediately.When the application is linked with a debug version of the run-time libraries,
assert
creates a message box with three buttons:Abort
,Retry
, andIgnore
. If the user clicksAbort
, the program aborts immediately. If the user clicksRetry
, the debugger is called and the user can debug the program if just-in-time (JIT) debugging is enabled. If the user clicksIgnore
,assert
continues with its normal execution: creating the message box with theOK
button. Note that clickingIgnore
when an error condition exists can result in undefined behavior....
The
assert
macro is enabled in both the release and debug versions of the C run-time libraries whenNDEBUG
is not defined. WhenNDEBUG
is defined, the macro is available but does not evaluate its argument and has no effect. When it is enabled, theassert
macro calls_wassert
for its implementation. Other assertion macros,_ASSERT
,_ASSERTE
and_ASSERT_EXPR
, are also available, but they only evaluate the expressions passed to them when the_DEBUG
macro has been defined and when they are in code linked with the debug version of the C run-time libraries.
So, if you want to disable this particular popup error, you need to either:
find the root cause of the error and fix it (or contact the Unity author to fix it), since it is a code bug.
compile masterserver.exe
for release instead of debug, so RakAssert()
is a no-op.
define NDEBUG
in the source code, in the project solution, or via the compiler's /D
switch on the command-line, so assert()
is a no-op.
Just know that disabling the assertion will risk the app crashing or behaving incorrectly if the error happens again.
Upvotes: 1