| Issue |
233396
|
| Summary |
[mlir][xegpu] SIGSEGV in an MLIR API driver on the upstream test_load_nd_vc_3 input (13c6abf)
|
| Labels |
mlir
|
| Assignees |
|
| Reporter |
lin334141-cell
|
A small MLIR-based parsing/verification and IR-facts driver terminated with SIGSEGV while processing the `test_load_nd_vc_3` example from the same LLVM revision's test suite. The test expects a warning for `packed` on a one-dimensional descriptor. I am reporting the saved integration observation and providing the original input, complete driver source and recovered build information so the failure can be investigated. Its location within MLIR or the custom driver has not been determined.
## Environment
- LLVM/MLIR revision recorded for this tool: `13c6abfac84fca4bc55c0721d1853ce86a385678` (2025-01-21).
- Tool: custom `ggfa-ir-facts-r1`, Linux x86-64, reading stdin with no command-line options. The supplied driver parses and verifies a module, walks it to collect type/operation facts, then prints JSON and canonical IR. It does not execute a transformation pass or GPU code.
- Historical driver build: GCC 7.5.0, CMake 3.26.4, Unix Makefiles, Release, C++17. Its generated compile flags end in `-UNDEBUG`.
- Observed executable SHA-256: `1cd422f2411a363f4bb66c5cecdaaab883788ae0585bbe1ab83f728e93766f83`. A retained executable in the recovered build directory has the same SHA-256; its source/object dependencies, compile flags, link command and completed build log were recovered together.
## Reproducer
This is the complete saved 321-byte stdin, unchanged by this review. It came from [the upstream regression test](https://github.com/llvm/llvm-project/blob/13c6abfac84fca4bc55c0721d1853ce86a385678/mlir/test/Dialect/XeGPU/invalid.mlir#L72-L79), with only its `expected-warning` comment omitted during the original extraction.
```mlir
func.func @test_load_nd_vc_3(%src: memref<8x16xf16>) {
%1 = xegpu.create_nd_tdesc %src[0, 0] : memref<8x16xf16> -> !xegpu.tensor_desc<16xf16>
%2 = xegpu.load_nd %1 <{packed, l1_hint = #xegpu.cache_hint<cached>, l2_hint = #xegpu.cache_hint<uncached>}>
: !xegpu.tensor_desc<16xf16> -> vector<16xf16>
return
}
```
SHA-256: `8568f07a986fca8679f144e7ad9a63416fb73a54a63d0a2076a831c0691c25a7`.
## Steps to reproduce
The observed invocation supplied the input above to `ggfa-ir-facts-r1` on stdin, with no additional arguments. In shell notation, the saved invocation is:
```sh
ggfa-ir-facts-r1 < input.mlir
```
The actual driver is supplied below; this observation is not a run of `mlir-opt`. The recovered CMake file and build details identify the historical integration, rather than substituting a different driver. The source and configuration have not been rebuilt or rerun as part of this material recovery.
<details>
<summary>Complete historical driver: ir_facts_r1.cpp</summary>
```cpp
// Read-only, verifier-backed IR facts. No pass execution or source generation.
#include "mlir/IR/AsmState.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Verifier.h"
#include "mlir/InitAllDialects.h"
#include "mlir/Parser/Parser.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
using namespace mlir;
namespace json = llvm::json;
static std::string printType(Type type) {
std::string s;
llvm::raw_string_ostream stream(s);
type.print(stream);
return s;
}
static json::Object typeFacts(Type type) {
json::Object result{{"text", printType(type)}, {"kind", "other"}};
if (auto integer = dyn_cast<IntegerType>(type)) {
result["kind"] = "integer";
result["width"] = int64_t(integer.getWidth());
} else if (isa<IndexType>(type)) {
result["kind"] = "index";
}
if (auto shaped = dyn_cast<ShapedType>(type)) {
result["kind"] = isa<BaseMemRefType>(type) ? "memref" :
isa<TensorType>(type) ? "tensor" : "shaped";
result["element_type"] = printType(shaped.getElementType());
result["ranked"] = shaped.hasRank();
json::Array shape;
if (shaped.hasRank())
for (int64_t dim : shaped.getShape())
shape.push_back(ShapedType::isDynamic(dim) ? json::Value(nullptr) : json::Value(dim));
result["shape"] = std::move(shape);
if (auto memref = dyn_cast<MemRefType>(type)) {
std::string layout;
llvm::raw_string_ostream stream(layout);
memref.getLayout().print(stream);
result["layout"] = layout;
SmallVector<int64_t> strides;
int64_t offset;
if (succeeded(memref.getStridesAndOffset(strides, offset))) {
result["offset"] = ShapedType::isDynamic(offset) ? json::Value(nullptr) : json::Value(offset);
json::Array values;
for (int64_t stride : strides)
values.push_back(ShapedType::isDynamic(stride) ? json::Value(nullptr) : json::Value(stride));
result["strides"] = std::move(values);
}
}
}
return result;
}
int main(int argc, char **argv) {
if (argc != 1) {
llvm::errs() << "usage: ggfa-ir-facts-r1 < input.mlir\n";
return 2;
}
auto input = llvm::MemoryBuffer::getSTDIN();
if (!input || (*input)->getBufferSize() > 262144) {
llvm::errs() << "input missing or exceeds admitted 262144 bytes\n";
return 2;
}
DialectRegistry registry;
registerAllDialects(registry);
MLIRContext context(registry);
context.disableMultithreading();
llvm::SourceMgr mgr;
mgr.AddNewSourceBuffer(std::move(*input), llvm::SMLoc());
auto module = parseSourceFile<ModuleOp>(mgr, &context);
if (!module || failed(verify(*module))) {
llvm::outs() << "{\"schema\":\"ggfa.ir_facts.r1\",\"verified\":false}\n";
return 1;
}
llvm::DenseMap<Operation *, int64_t> opIds;
llvm::DenseMap<Value, int64_t> valueIds;
llvm::DenseMap<Region *, int64_t> regionIds;
int64_t oi = 0, vi = 0, ri = 0;
module->walk<WalkOrder::PreOrder>([&](Operation *op) {
opIds[op] = oi++;
for (Value value : op->getResults()) valueIds[value] = vi++;
for (Region ®ion : op->getRegions()) {
regionIds[®ion] = ri++;
for (Block &block : region)
for (Value value : block.getArguments()) valueIds[value] = vi++;
}
});
if (oi > 4096) {
llvm::errs() << "operation bound exceeded\n";
return 2;
}
auto valueFact = [&](Value value) {
return json::Object{{"id", valueIds.lookup(value)}, {"type", typeFacts(value.getType())}};
};
json::Array operations;
module->walk<WalkOrder::PreOrder>([&](Operation *op) {
json::Object node{{"id", opIds.lookup(op)}, {"name", op->getName().getStringRef().str()},
{"regions", int64_t(op->getNumRegions())},
{"loop_like", isa<LoopLikeOpInterface>(op)}};
node["parent"] = op->getParentOp() ? json::Value(opIds.lookup(op->getParentOp())) : json::Value(nullptr);
node["region"] = op->getParentRegion() ? json::Value(regionIds.lookup(op->getParentRegion())) : json::Value(nullptr);
json::Array operands, results, arguments;
for (Value value : op->getOperands()) operands.push_back(valueFact(value));
for (Value value : op->getResults()) results.push_back(valueFact(value));
for (Region ®ion : op->getRegions())
for (Block &block : region)
for (Value value : block.getArguments()) arguments.push_back(valueFact(value));
node["operands"] = std::move(operands);
node["results"] = std::move(results);
node["block_arguments"] = std::move(arguments);
if (auto linalg = dyn_cast<linalg::LinalgOp>(op))
node["linalg_semantics"] = linalg.hasPureTensorSemantics() ? "tensor" :
linalg.hasPureBufferSemantics() ? "buffer" : "mixed";
if (auto load = dyn_cast<memref::LoadOp>(op))
node["access_memref"] = valueIds.lookup(load.getMemRef());
if (auto store = dyn_cast<memref::StoreOp>(op))
node["access_memref"] = valueIds.lookup(store.getMemRef());
operations.push_back(std::move(node));
});
std::string canonical;
llvm::raw_string_ostream stream(canonical);
module->print(stream, OpPrintingFlags().enableDebugInfo(false));
json::Object result{{"schema", "ggfa.ir_facts.r1"}, {"verified", true},
{"operations", std::move(operations)}, {"canonical_ir", canonical}};
llvm::outs() << json::Value(std::move(result)) << "\n";
return 0;
}
```
</details>
<details>
<summary>Historical CMakeLists.txt</summary>
```cmake
cmake_minimum_required(VERSION 3.20)
project(mlirvkf_native LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(MLIR REQUIRED CONFIG)
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}" "${LLVM_CMAKE_DIR}")
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)
include_directories(${LLVM_INCLUDE_DIRS} ${MLIR_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
add_llvm_executable(ggfa-ir-facts-r1 ir_facts_r1.cpp)
llvm_update_compile_flags(ggfa-ir-facts-r1)
get_property(MLIRVKF_DIALECT_LIBS GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(MLIRVKF_EXTENSION_LIBS GLOBAL PROPERTY MLIR_EXTENSION_LIBS)
target_link_libraries(ggfa-ir-facts-r1 PRIVATE
${MLIRVKF_DIALECT_LIBS} ${MLIRVKF_EXTENSION_LIBS} MLIRIR MLIRParser
MLIRLinalgDialect MLIRMemRefDialect MLIRLoopLikeInterface LLVMSupport)
mlir_check_all_link_libraries(ggfa-ir-facts-r1)
install(TARGETS ggfa-ir-facts-r1 RUNTIME DESTINATION bin)
```
</details>
<details>
<summary>Recovered compiler, linkage and configuration details</summary>
**Recovered historical build information**
These are saved build records, not results from a new configure/build or execution.
- LLVM/MLIR revision recorded for the tool: `13c6abfac84fca4bc55c0721d1853ce86a385678` (2025-01-21).
- Executable: ELF x86-64; GNU build ID `84ca44170004c19c6ba4d329eeff5740b70a5486`.
- Executable SHA-256: `1cd422f2411a363f4bb66c5cecdaaab883788ae0585bbe1ab83f728e93766f83`.
- CMake 3.26.4, generator `Unix Makefiles`, `CMAKE_BUILD_TYPE=Release`, C++17.
- Driver compiler: `/usr/bin/c++`, GNU 7.5.0; ELF comment identifies Ubuntu 7.5.0-3ubuntu1~18.04.
- The generated compile rule ends with `-UNDEBUG`; the Release setting alone therefore does not imply assertions were disabled.
- `LLVM_DIR` and `MLIR_DIR` pointed into the same LLVM build tree, whose source include paths name the revision above.
- `DependInfo.cmake` and the generated compile rule name the supplied `ir_facts_r1.cpp`; the generated link rule names its object and `ggfa-ir-facts-r1`.
- The saved build log ends in successful compile/link/target-completion records. A retained executable from this build directory is byte-identical to the checker hash in the failed call.
- Source, object and executable modification times are 2026-09-23 14:24:40, 14:25:16 and 14:25:27 UTC respectively. These support the artifact association; they are not a reproducible-build attestation.
Actual driver compile definitions/flags from `flags.make` (unchanged):
```text
CXX_DEFINES = -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
CXX_FLAGS = -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-nonnull -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=gnu++1z -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-exceptions -funwind-tables -fno-rtti -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG
```
The supplied historical `CMakeLists.txt` is the configuration entry point. It links the MLIR dialect and extension libraries plus MLIR IR/parser, Linalg, MemRef, LoopLikeInterface and LLVMSupport. The generated historical link line contains 327 static archive references (244 distinct names), including `MLIRXeGPUDialect` and `MLIRXeGPUTransforms`. ELF dependencies are `libdl.so.2`, `libpthread.so.0`, `libz.so.1`, `libstdc++.so.6`, `libm.so.6`, `libgcc_s.so.1`, `libc.so.6` and `ld-linux-x86-64.so.2`; there is no dynamic MLIR/LLVM library entry.
To configure this recovered project, the two CMake package variables must reference `lib/cmake/llvm` and `lib/cmake/mlir` in a build of the stated revision; the historical target is `ggfa-ir-facts-r1`. No new build recipe, compiler flags or executed result is being substituted for the recovered files.
The original LLVM build tree and its full CMake cache are no longer present at the recorded location. The recovered files identify the historical driver build, but a byte-for-byte rebuild, the original runtime shared-library versions, and the failure location have not been established.
</details>
## Actual behavior
The saved process record reports:
```text
status: SIGNAL
return_code: -11 (SIGSEGV, as reported by the subprocess API)
reaped: true
stdout: 0 bytes
stderr: 0 bytes
elapsed: 0.289126 seconds
configured timeout: 10 seconds
```
No assertion text, warning or backtrace was captured. The process record classifies the termination as a signal, not a timeout. It does not identify the failing function.
## Expected behavior
At the stated revision, the [upstream test](https://github.com/llvm/llvm-project/blob/13c6abfac84fca4bc55c0721d1853ce86a385678/mlir/test/Dialect/XeGPU/invalid.mlir#L72-L79) expects `Invalid Packed Attr.` for this exact function. In [LoadNdOp::verify](https://github.com/llvm/llvm-project/blob/13c6abfac84fca4bc55c0721d1853ce86a385678/mlir/lib/Dialect/XeGPU/IR/XeGPUOps.cpp#L227-L289), `packed` on a rank-one descriptor emits a warning and is ignored for verification; both descriptor and result shapes here are `[16]`. The warning's display depends on the diagnostic handler installed by the driver.
I would expect this integration to finish verification/fact extraction, or report an ordinary diagnostic for an unsupported use. If the driver violates an MLIR API requirement, identifying that requirement would also resolve the report; I am not claiming that a transformation of a valid program was miscompiled.
## Analysis
The recovered driver registers all dialects and disables multithreading. It calls `parseSourceFile<ModuleOp>` and `verify`, then inspects operation/value/type information and prints the module. Its historical link records include the XeGPU dialect library. Nothing in the saved logs identifies which of these stages failed, and the same input has not been tested through standard `mlir-opt` in this review.
The evidence is limited to the saved custom-driver invocation on the revision above. There is no new independent replay, latest-version result, symbolized fault location or verified patch. The driver build records were recovered, but the full original LLVM build cache and historical runtime shared-library identities are not available. A byte-identical rebuild is therefore not c<truncated>Please see the issue for the entire body.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs