"metallib" generates unpredictable results.

Hi, I am using metallib to generate shader cache shaders offline, but I have noticed that for certain .air files, metallib's behavior is unpredictable. Sometimes it runs correctly, sometimes it may crash or generate an invalid .lib file.

// crash info
0x00007FF6705AA821 (0x000001C5F7218E30 0x00000084F9F8F089 0x000001C5F72B57E0 0x000001C5F7218E30)
0x00007FF6705A9062 (0x00007FF6709200E0 0x000001C5F7208CE0 0x0000000000000002 0x00007FF670920140)
0x00007FF6704C8FD6 (0x00007FF6709200E0 0x00007FF600000000 0x00007FF670920140 0x0000000000000000)
0x00007FF66FF7F1F4 (0x0000000000000000 0x000001C5F71EC210 0x000001C5F71EC210 0x0000000000000000)
0x00007FF66FF6C8D1 (0x0000000000000004 0x000001C5F71EC210 0x0000000000000000 0x0000000000000000)
0x00007FF670633974 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)
0x00007FFB9C137614 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), BaseThreadInitThunk() + 0x14 bytes(s)
0x00007FFB9DB826A1 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), RtlUserThreadStart() + 0x21 bytes(s)

I tried the latest version (Metal Tools for Windows 4.1), but the issue still exists.

I placed the input .air file at:

https://drive.google.com/file/d/1MQQRbwKi-bcEZ9jy_dimRjJBovjB0ru2/view?usp=drive_link

Sounds like a bug, could you include the shaders and commands you ran in a bug report on Feedback Assistant? Also post the feedback ID here for record keeping.

Thanks for sharing the .air file. It would be great if you could also provide the command line you used here. I tried to reproduce this with:

"C:\Program Files\Metal Developer Tools\metal\ios\bin\metal.exe" --version
Apple metal version 32023.35 (metalfe-32023.35-windows)

"C:\Program Files\Metal Developer Tools\metal\ios\bin\metal.exe" -target air64-apple-ios9.0 -o default.metallib a.air

I ran it 1000 times and it never failed.

I used the metallib.exe as follows:

C:\Program Files\Metal Developer Tools\metal\ios\bin>metallib.exe --version
AIR-LLD 32023.35 (metalfe-32023.35-windows) (compatible with legacy metallib linker)

C:\Program Files\Metal Developer Tools\metal\ios\bin>metallib.exe -o a.metallib a.air

C:\Program Files\Metal Developer Tools\metal\ios\bin>metallib.exe -o a.metallib a.air
0x00007FF73172DFD3 (0x00007FF731AFB230 0x000001CCAD1D09A0 0x0000000000000080 0x00007FF731664950)...

Thanks for that command line, I am able to reproduce this locally too. Can you adopt the metal.exe workflow instead since that works for me and is the recommended path. Meanwhile, if you can provide a Feedback ID for this, you can track the fix for this automatically.

"metallib" generates unpredictable results.
 
 
Q