[webkit-changes] [WebKit/WebKit] e9d5f6: [WGSL] Keep source alive for as long as AST is alive

Tadeu Zagallo noreply at github.com
Fri Jan 27 02:17:23 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e9d5f63ecb2ca601e84b1f0cc2c23f63c43d21c2
      https://github.com/WebKit/WebKit/commit/e9d5f63ecb2ca601e84b1f0cc2c23f63c43d21c2
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-01-27 (Fri, 27 Jan 2023)

  Changed paths:
    M Source/WebGPU/WGSL/AST/ASTShaderModule.h
    M Source/WebGPU/WGSL/Parser.cpp
    M Source/WebGPU/WGSL/Parser.h
    M Source/WebGPU/WGSL/ParserPrivate.h
    M Tools/TestWebKitAPI/Tests/WGSL/ParserTests.cpp

  Log Message:
  -----------
  [WGSL] Keep source alive for as long as AST is alive
https://bugs.webkit.org/show_bug.cgi?id=251204
<rdar://problem/104691207>

Reviewed by Myles C. Maxfield.

The `Identifier`s generated by the parser keep a reference and offset to the input source,
but no references are kept to make sure the source stays around, which resulted in it
being deallocated while the AST was still in use. I added a test that crashes if Guard Malloc
is enabled.

* Source/WebGPU/WGSL/AST/ASTShaderModule.h:
* Source/WebGPU/WGSL/Parser.cpp:
(WGSL::parse):
(WGSL::Parser<Lexer>::parseShader):
* Source/WebGPU/WGSL/Parser.h:
* Source/WebGPU/WGSL/ParserPrivate.h:
* Tools/TestWebKitAPI/Tests/WGSL/ParserTests.cpp:
(TestWGSLAPI::TEST):

Canonical link: https://commits.webkit.org/259472@main




More information about the webkit-changes mailing list