Page MenuHome

"Saving As..." a blend file with a Script node file path filled with 1023 symbols crashes Blender.
Closed, ResolvedPublic

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: NA
Blender Version
Broken: version: 2.79b through current master 2.91 rB4bf6ffc022fd

Short description of error
Trying to "Save As..." a new .blend file with a Script node set to external and the path filled with 1023 symbols will crash Blender and leave a 0KB .blend@ file.

I was trying to find a way to store a JSON inside a node group. I will try adding a custom property. https://docs.blender.org/manual/en/2.90/files/data_blocks.html#files-data-blocks-custom-properties

Exact steps for others to reproduce the error
1. Open a new file.
2. Create a material and a script node.
3. Set the script node to external and fill the path with the max length string (1024 symbols).
4. "Save As..." or "Save Copy..." the blend file.

NOTE: Steps 2 & 3 can be done by opening the scripting workspace and running the following python code:
A script to reproduce the error
import bpy

bpy.ops.mesh.primitive_cube_add()
new_material = bpy.data.materials.new(name="New Test Material")
new_material.use_nodes = True
bpy.context.active_object.data.materials.append(new_material)

nodes = new_material.node_tree.nodes

for node in nodes:
    nodes.remove(node)

node_group = new_material.node_tree.nodes.new( type = 'ShaderNodeScript' )

nodes["Script"].mode = 'EXTERNAL'
nodes["Script"].filepath = "A"*1023

Event Timeline

Random guessing and no research says you are running up against maximum path length on your platform.

Evan Wilson (EAW) closed this task as Invalid.EditedOct 3 2020, 10:58 PM
Evan Wilson (EAW) claimed this task.

Windows has a max file path length of 260. In order to exceed this you have to enable long paths.
https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

If you want to store text, use the text editor under the scripting workspace.
https://docs.blender.org/manual/en/2.90/editors/text_editor.html

Closing this as it appears to be an issue with the default path length on Windows and not an issue with Blender. If this is not the case, let us know and this can be reopened.

It has nothing to do with long paths. I even have them enabled. Did you follow "Exact steps for others to reproduce the error"? I think it is because Blender adds //..\ and crashes because of the 1023 chars limit. If I remove 5 symbols, it doesn't crash.

A script to reproduce the error
import bpy

bpy.ops.mesh.primitive_cube_add()
new_material = bpy.data.materials.new(name="New Test Material")
new_material.use_nodes = True
bpy.context.active_object.data.materials.append(new_material)

nodes = new_material.node_tree.nodes

for node in nodes:
    nodes.remove(node)

node_group = new_material.node_tree.nodes.new( type = 'ShaderNodeScript' )

nodes["Script"].mode = 'EXTERNAL'
nodes["Script"].filepath = "A"*1023
Evan Wilson (EAW) reopened this task as Confirmed.Oct 21 2020, 10:30 PM

@Roman Markov (unwave) I missed the notification of your Oct 12th reply, sorry about that. Thanks for the PM to remind me.

Thanks to your script, I have a better understanding of the issue and I have been able to reproduce.

I think it is because Blender adds //..\ and crashes because of the 1023 chars limit.

I agree. In my test 17 symbols were added due to the location at which I tried to save the file.

//..\\..\\..\\..\\..\\

Blender crashes at:

blender.exe!rewrite_path_fixed(unsigned char * path=0x0000022f06ced330, bool(*)(void *, unsigned char *, const unsigned char *) visit_cb=0x00007ff767b2b260, const unsigned char * absbase=0x0000000000000000, void * userdata=0x0000004fd3ffc958) Line 481
	at C:\blender-git\blender\source\blender\blenkernel\intern\bpath.c(481)

Run-Time Check Failure #2 - Stack around the variable 'res' was corrupted.

Continuing results in:

Run-Time Check Failure #2 - Stack around the variable 'path_dst' was corrupted.

Continuing again allows me to save the file.

It seems like there should be a check to make sure that rewriting the path does not exceeded the max length.


Tested using rB4bf6ffc022fd

Evan Wilson (EAW) removed Evan Wilson (EAW) as the assignee of this task.Oct 21 2020, 10:49 PM
Evan Wilson (EAW) updated the task description. (Show Details)