newLibraryWithSource Crash when bundle path containing chinese characters

Hey, recently our app need adapt to new m1 MacBook and Big Sur. It crashed on newLibraryWithSource of Metal.framework when recompiling our app. I created a minimal demo originated from an official metal example to reproduce this problem. To trigger this crash a MacBook(m1 or intel cpu) with Big Sur is needed, besides there are three steps to follow after cloning my demo:
  1. open project with xcode, switch target to HelloTriangle-macOS.

  2. open File->Project Settings->Advanced, change Build Location to what containing Chinese characters.

  3. open Product->Scheme->Edit Scheme, check Address Sanitizer for HelloTriangle-macOS target on Diagnostics tab.

Then press command+R to launch the project, this crash will appear. I find this bug on most MacBook with Big Sur of both m1 and intel cpu, while it seemed not appear on iMac Big Sur
Temporarily fix by swizzling resourcePath. But I think it's probably a bug of Matal.framework
Feral Interactive Hitman 2016 port had the same issue, because the application name contained the ™ character.

But on macOS 11.3 beta 2 I can run it, so probably it has been fully or partially fixed (tested only on AMD gpu).
Indeed this sounds like a bug in the Metal framework. Please create ticket with Feedback Assistant. If you post the number back here I will able to get it to the right engineers more quickly.



Sorry for my late reply, I have created a feedback with number FB9022420, thanks!


Indeed this sounds like a bug in the Metal framework. Please create ticket with Feedback Assistant. If you post the number back here I will able to get it to the right engineers more quickly.



This link with the reproducer you put in your FBA ticket isn't working for me:
https://github.com/FinleyPan/MET_newLibraryWithSource_Test)

It's odd that this occurs with -[MTLDevice newLibraryWithSource:...] since you don't use a path in this method (you just pass the Metal source as a string). I might expect a problem with newLibraryWithBundle, newLibraryWithFile or newLibraryWithURL since those methods do take paths as an argument.
Because our project targets to multiple platforms, So shaders are compiled at runtime. We analyzed call stack of newLibraryWithSource, it will call TLLibraryBuilder::newLibraryWithSource which acquired resourcePath of mainBundle to serve as the working directory to compile shaders(a parameter named -working-directory). So I think there are some relationships between bundle path and shader compilation. Our workaround is swizzling resourcePath to "." when call newLibraryWithSource.


Can you provide access to your GitHub project? I still get a 404 when I use it.
sorry for typo in above link, try this: https://github.com/FinleyPan/Metal_newLibraryWithSource_Test
Wow. I'm definitely able to reproduce this with your project if I rename one of the folders in the path to Shaders.txt with Chinese characters. I'll get someone to look at it. Thanks for the reproducer.
Cool! Look forward to your fix :)
newLibraryWithSource Crash when bundle path containing chinese characters
 
 
Q