3dsmax Batch always exits with code -130

3dsmax Batch always exits with code -130

h.schoenberger
Enthusiast Enthusiast
4,490 Views
15 Replies
Message 1 of 16

3dsmax Batch always exits with code -130

h.schoenberger
Enthusiast
Enthusiast

Hi

 

I have written a python script that I want to execute with 3dsmax Batch.

Although there is no error message (not in the system log as well), it exits with code -130.


The 3dsmax help recommends to execute "quitMAX quiet:true exitCode:0" to override the exit code.
As I am using a python script, I execute

from pymxs import runtime as rt
rt.quitMax(exitCode=0, quiet=True) 

This command crashes the maxScript interpretor (system log).

 

So I wrote a .ms Maxscript wrapper that calls my python script.
And that one executes

quitMAX quiet:true exitCode:0 

 

But this has no effect on the exit code as well.

 

 

 


The issue seems to be related to using a the python logging module to create a logger.

This logger connects to the default stream handler with logging.StreamHandler() and prints a message.

Just creating the logger object without printing anything does not cause 3dsmaxBatch to exit with code -130.

 

0 Likes
Accepted solutions (1)
4,491 Views
15 Replies
Replies (15)
Message 2 of 16

attilaszabo
Alumni
Alumni

Hello @h.schoenberger ,

-130 means that 3dsmax.exe reported an error to 3dsmaxbatch.exe (3dsmaxbatch.exe launches 3dsmax.exe in a special non-interactive mode as a child process).

Could you run your 3dsmaxbatch task with the highest logging level (-v 5) and post here the line "3ds Max Exit Code =<error code>"

 

Also, what version of 3ds Max and what version of Python are you using?
3ds Max 2021 ships both Python 3 (3.7.6) and Python 2 (2.7.17)

 

Thanks

Attila

 

Attila Szabo
Product Owner, 3ds Max
Autodesk
0 Likes
Message 3 of 16

attilaszabo
Alumni
Alumni

If you could also post the shortest python script that reproduces the problem that would help us a lot.

 

Thanks

Attila

Attila Szabo
Product Owner, 3ds Max
Autodesk
0 Likes
Message 4 of 16

h.schoenberger
Enthusiast
Enthusiast

Hi


It uses python 3.  (The 3dsmax UI was never started with this user preference folder, the preferences have never been changed, it is a fresh install)

I have attached the log output of the console including an echo line that shows that the exit code is -130.

Although 3dsmax prints that the exit code should be 0.
And it prints "Task Completed with Error(s)", but there was no error message.

In addition the system log of the same execution.


And the script I used.

As you can see I have commented out

rt.quitMax(exitCode=0, quiet=True)
as this command crashes the script interpretor.
(I did a test using a maxscript wrapper as stated in my first post, but this had no effect on the exit code)

0 Likes
Message 5 of 16

Anonymous
Not applicable

You just need to run

from pymxs import runtime as rt
rt.quitMax()

in Python3 in 3ds Max 2021. Python 2 seems to work ok in just a default installation but it crashes on our renderfarm. So that might be related to the logging that Holger mentioned.

Python3 crashes even without any external logging interventions.

It doesn't matter if it's batch or interactive. It always crashes and my Visual Studio debugger pops up.

This is a really painful issue that is causing our pipeline to always think that 3dsmax crashed. It should be bumped in priority and fixed asap.

0 Likes
Message 6 of 16

attilaszabo
Alumni
Alumni

Thank you for the extra information. We are looking into a fix for this problem.

 

Attila

Attila Szabo
Product Owner, 3ds Max
Autodesk
0 Likes
Message 7 of 16

eric.brosseau
Autodesk
Autodesk

Hi @h.schoenberger ,

I was not able to reproduce the issue with a simple script so far, but I was able to find the reason for the script you provided in the thread not to complete properly. The Python logging module will report all of its messages on stderr by default. 3ds Max redirects all outputs to stderr (from Python or MAXScript) as an error. When running your script, 3ds Max Batch understands something was sent to stderr and will report the execution as faulty.

 

You can initialize your logging.StreamHandler like this so it outputs everything to stdout.

 

str_handler = logging.StreamHandler(sys.stdout)

 

 

Would this be enough on your side to unblock the situation you are in ?

 

As for a possible crash with a simple Python script making use of a 'runtime.quitMax()' call, I was not able to confirm the issue so far. I am using 3ds Max 2021 with Python 3.

Eric Brosseau
Senior Software Developer, 3ds Max, Autodesk
0 Likes
Message 8 of 16

h.schoenberger
Enthusiast
Enthusiast

Hi

 

Thanks Eric, but it does not yet solve the issue.

I have not seen the stderr issue as pythons stderr is redirected by 3dsmax into stdout.

I tested to use stdout.  And the results are that 3dsmax does not detect an error message.
BUT on the other side, it does not print the message as well. So this is not a solution for us.

Is there any env var or function to tell 3dsmax to forward stdout?
Or is this a limitation of the process pipe between 3dsmaxbatch and 3dsmax?


(Still waiting for a "real" 3dsmaxbatch that does not call any UI. Or at least as a first step that 3dsmaxbatch.exe does not start a second 3dsmax.exe app. Similar to Maya I/O, which is in fact maya UI exe that still loads UI libs, but uses a different license and does not show the UI. Although Autodesk told me in a meeting some years ago that Maya I/O will not use UI libs at all once finished...)

 

>I was not able to reproduce the issue with a simple script so far

There are 3 issues:

a) Unable to print messages if not using stderr.

b) Using runtime.quitMax() crashes 3dsmax

c) Even if I  use maxscript as a wrapper for the python script to set the exit code and 3dsmax logs that the exit code will be 0, the exit code is still -130.

 

About b)

>as for a possible crash with a simple Python script making use of a 'runtime.quitMax()' call, I was not able to confirm the issue so far
I tested to run the commands in 3dsmx UI as jens.l stated and I can confirm the crash.
New 3dsmax installation, open 3dsmax UI, write, save and execute the script

 

 

from pymxs import runtime as rt
rt.quitMax(exitCode=0, quiet=True)

 

Note: You need to have for example Visual Studio installed. Then it opens a dialog to debug the crashed code. 3dsmax does not open its own crash reporter.

 

.

0 Likes
Message 9 of 16

eric.brosseau
Autodesk
Autodesk

I will further investigate the issue you are reporting @h.schoenberger. There is definitely something not properly completing. Thanks for your patience (with me). We will report back once we identify the possible issue and resolution.

 

As for 3ds Max Batch not reporting the stdout output of an executed script, there is a precision to be made. You need to use the -listenerlog option of 3ds Max Batch to get the output of script execution sent to a file for later parsing, as described in the documentation section 'Getting Information About Your 3ds Max Batch Job'. Only errors are broadcasted back to the 3ds Max Batch console.

 

Eric Brosseau
Senior Software Developer, 3ds Max, Autodesk
0 Likes
Message 10 of 16

h.schoenberger
Enthusiast
Enthusiast

>Thanks for your patience (with me).
No Problem. The current reply was fast. I am used to waaay slower comminication reporting bugs, but that was via the ADN support channel. And once it took me 2 months to get to the dev team via ADN and more months to get the issue fixed. Although it was a huge issue  (it was not possible to batch-render any more after a service pack update)


>You need to use the -listenerlog option
In the end we want to provide the end-customer a log file that contains all information about the current process.

Which means we need the stdout for the calling environment and for the startup messages of 3dsmaxbatch.exe.
Then we need the messages reported by our script, which should be in order (time-wise) with the 3dsmaxbatch.exe messages.
We already have to use the system log as there was no other way to get some error messages. This second system log file is only required if there is an issue not logged by (better: forwarded via) 3dsmaxbatch.exe.
Anyway, as it does not seem to be possible we will implement our own seperated logfile for our messages only. And we parse stdout and parse our log file every few seconds and merge them. (Which is not possible via listenerlog as this logfile needs to be closed by 3dsmax (our script) after each message to be able to clear it)

Which means that we have a workaround for the log messages now.
And with the workaround we do not need to call quitmax any more.

0 Likes
Message 11 of 16

Anonymous
Not applicable

Been busy these last couple of days... But if I understand everything correctly there's actually two issues...

1. If anything is written to stderr during 3dsmaxbatch, it will return with -130 error code. This is by design so now we now how to work around it.

2. 3ds Max is actually crashing when using rt.quitMax() with Python3 in interactive mode. It has exitcode -1073741819. I just tested in 3dsmaxbatch and that doesn't crash with rt.quitMax(). I wrote a test script that I have attaced here that demonstrates the problem. When in interactive, open and execute the python file in the script editor.

 

I thought these two was the same bug at first but it seems to be two different issues, right?

 

0 Likes
Message 12 of 16

h.schoenberger
Enthusiast
Enthusiast

Hi

Yes, there are multiple issues. To recap:


a) It is not possible to print anything to stdOut via 3dsmaxBATCH.exe.
stdErr is detected as an error message and causes 3dsmaxBATCH to exit with -130.
Workaround: a seperated log file.

b) rt.quitMax()  crashes 3dsmax.exe interactive.
3dsmaxBATCH calls 3dsmax.exe. rt.quitMax() does not seem to crash 3dsmax, but causes this error message in the 3dsmax system log:

 

[04908] [13476] Traceback (most recent call last): File "kso_3dsmax_pymxs.py". RuntimeError: MAXScript exception raised. -- 3ds Max Shutdown
[04908] [13476] MAXScript ExecuteMAXScriptScript Exception: -- Runtime error: Traceback (most recent call last): File "kso_3dsmax_pymxs.py"  RuntimeError: MAXScript exception raised. -- 3ds Max Shutdown

 

Workaround: rt.quitMax() is not required if we do not need to change the exit code any more.

c) There is no way to tell 3dsmaxBatchnot to use any error code if stderr was used. I assume this is the case for other issues as well. The last lines of 3dsmaxBatch.exe are
Task Completed with Error(s) - see above     <= stderr was used, so 3dsmaxBatch will exit with error code -130

3ds Max Shutting Down

3ds Max Exit Code = 0      <= 3dsmax exits with error code 0, but this does not change the exit code of 3dsmaxBATCH

Workaround: not required as we try not to cause any stderr message.



So in the end there are still some issues ang bugs, but it is possible to work around it.
At least for 3dsmaxbatch, not for 3dsmax UI/interactive.

Message 13 of 16

eric.brosseau
Autodesk
Autodesk
Accepted solution

@h.schoenberger ,

We have been looking a bit more into the exception log and it has been fixed it (no more exception thrown in the log and the Python script execution will halt beyond that call). The fix will be available in an update for 3ds Max 2021 but I do not know when it will be released and in which update it will be integrated. Thank you for reporting the problem to us.

 

 

 

Eric Brosseau
Senior Software Developer, 3ds Max, Autodesk
Message 14 of 16

victorEFVH7
Enthusiast
Enthusiast

Hi, 

 

sorry for digging up an old thread but its the same error code in 3dsmax 2023. I cant get it to exit with 0 even though I force it with quitmax and code 0

 

Is it possible to fake it somehow and send code 0 back to cmd even though it hasnt been closed?

0 Likes
Message 15 of 16

petrCDS7Y
Contributor
Contributor

Re You need to use the -listenerlog option of 3ds Max Batch to get the output of script execution sent to a file for later parsing

Is there like ABSOLUTELY no way to pipe 3ds Max Batch into stdout???  @eric.brosseau 

0 Likes
Message 16 of 16

petrCDS7Y
Contributor
Contributor

"""It is not possible to print anything to stdOut via 3dsmaxBATCH.exe."""

Is it still true is 3ds max 2025???

0 Likes