Chinmay Kolhatkar - Vendor
09/30/2026, 1:43 PMRocky
09/30/2026, 1:44 PMFunctionContext class now contains a std::unique_ptr to starrocks::JavaUDAFUniqueContext, but the compiler cannot find the full definition of that type when trying to generate the default constructor or destructor.
Root Cause
In be/src/exprs/function_context.cpp, the constructor (and likely the destructor) is defined as = default;.
cpp
FunctionContext::FunctionContext() = default; // Line 80
When using std::unique_ptr<T>, the compiler must have the full definition of T (not just a forward declaration) to instantiate the default deleter, which calls sizeof(T).
This is likely surfacing now because:
1. GCC 14 is significantly stricter regarding template instantiations and incomplete types compared to the GCC 10/11 versions typically used for StarRocks builds.
2. The --format-lib flag builds a limited subset of the StarRocks codebase. It appears the header defining JavaUDAFUniqueContext is missing from the format-lib include path or is not included in function_context.cpp.
Suggested Fixes
1. Add the missing include
Locate the header file that defines JavaUDAFUniqueContext (usually be/src/exprs/java_udaf_context.h or similar) and include it in be/src/exprs/function_context.cpp.
cpp
// In be/src/exprs/function_context.cpp
#include "exprs/java_udaf_context.h" // Add this line
2. Ensure non-defaulted Destructor in .cpp
If the destructor is defaulted in the header file (function_context.h), move its definition to the .cpp file. This ensures the compiler only looks for the full definition of JavaUDAFUniqueContext inside the implementation file where the header is included.
3. Review Build Flags
The combination of --format-lib and --enable-shared-data is uncommon.
* --format-lib is intended for building the standalone columnar format library (often for external connectors).
* --enable-shared-data enables Cloud-Native (shared-storage) features.
If you do not specifically need Cloud-Native features in your format library, try building without `--enable-shared-data`:
bash
./build.sh --format-lib -j4
Recommendation for GCC 14
StarRocks' official build environment currently uses GCC 11 or Clang. GCC 14 may introduce other "conditionally-supported" warnings (like the offsetof warning you see in current_thread.h) that can be treated as errors if -Werror is enabled. If possible, use the official StarRocks build docker image to ensure compatibility.
If the issue persists after adding the include, it may be a bug in the recent main branch where Java UDF components were added to FunctionContext without proper guards for the format-lib target. You should report this on the StarRocks GitHub Issues.
References
• administration/management/FE_configuration.md
• administration/management/BE_configuration.md
• deployment/shared_data/s3.md
• deployment/shared_data/minio.mdChinmay Kolhatkar - Vendor
09/30/2026, 2:01 PMdev-env-ubuntu:4.1.3 to build from tag 4.1.3... Should I be using another dev-env-ubuntu?Rocky
09/30/2026, 2:01 PMdev-env-ubuntu:4.1.3 image) and a missing header dependency in the StarRocks source code.
1. Why it's happening
The error invalid application of 'sizeof' to incomplete type 'starrocks::JavaUDAFUniqueContext' happens because the class FunctionContext uses a std::unique_ptr<JavaUDAFUniqueContext>. In the file be/src/exprs/function_context.cpp, the constructor or destructor is "defaulted" (using = default;).
When using std::unique_ptr, the compiler must have the full definition of the managed type (not just a forward declaration) at the point where the destructor or constructor is defined, because it needs to know how to delete the object. GCC 14 is much more aggressive about checking this than the older GCC 11/12 versions.
2. How to fix it
You need to manually add the missing include to the implementation file so the compiler can see the full definition of JavaUDAFUniqueContext.
1. Open the file: be/src/exprs/function_context.cpp.
2. Add the following include at the top with the other includes:
cpp
#include "exprs/java_udaf_context.h"
(Note: If that specific path doesn't exist, search for the file defining class JavaUDAFUniqueContext in be/src/exprs/ and include that.)
3. Re-run your build command.
3. About the Build Environment
You are using dev-env-ubuntu:4.1.3 to build tag 4.1.3, which is the correct match. However, StarRocks recently moved to a newer toolchain (including GCC 14) for the 4.x series. This transition often uncovers "incomplete type" bugs like this one that were hidden in older compilers.
4. Build Flag Recommendation
You are using both --format-lib and --enable-shared-data.
* --format-lib is meant for building a standalone columnar library for external use (like the StarRocks Spark/Flink connectors).
* --enable-shared-data is for the cloud-native "Lake" architecture.
Unless you are specifically developing a connector that needs to read StarRocks' shared-data (lake) storage format directly, you usually don't need both. If the header fix above doesn't work or leads to more errors, try building with just the flag you absolutely need:
bash
./build.sh --format-lib -j4
# OR
./build.sh --be --enable-shared-data -j4
Summary: The image is likely correct, but the code in tag 4.1.3 has a minor header omission that GCC 14 caught. Adding the #include for the Java UDAF context in function_context.cpp should resolve the "incomplete type" error.Chinmay Kolhatkar - Vendor
09/30/2026, 2:04 PMRocky
09/30/2026, 2:05 PMdev-env-ubuntu tag to your StarRocks version is generally the correct approach, the 4.1.3 image has transitioned to GCC 14, which is significantly stricter than previous versions. The error you are seeing is a known side effect of this transition, specifically affecting builds where certain headers aren't explicitly included.
Should you use an older dev-env-ubuntu?
Generally, no. Moving to a significantly older image (like 3.x) might cause other issues because StarRocks 4.1 introduces dependencies (like newer versions of Thrift or specific C++20 features) that the older toolchains in 3.x images may not support.
However, if you want to avoid editing the source code and just need a working build, you can try:
* starrocks/dev-env-ubuntu:3.5-latest: This is a very stable build environment that uses GCC 11. Many 4.x components still compile fine with GCC 11, though you might run into issues with the absolute latest 4.1-specific features.
* starrocks/dev-env-ubuntu:4.0.x: If there is a 4.0.14 or similar tag, it likely uses a slightly older toolset (GCC 12 or 13) that may not trigger the "incomplete type" error.
Why the code fix is better
The "incomplete type" error is essentially a small bug in the StarRocks source code for the --format-lib build path. GCC 14 flags it, while GCC 11 allowed it to slide. By simply adding the missing header, you can continue using the modern, intended toolchain.
To fix the code in your current environment:
1. Open be/src/exprs/function_context.cpp.
2. Add this line near the top:
cpp
#include "exprs/java_udaf_context.h"
3. Re-run your build command.
A note on your build flags
The combination of --format-lib and --enable-shared-data is quite rare.
* --format-lib is typically used to build the standalone library for external connectors (like Spark/Flink).
* --enable-shared-data is for the Cloud-Native/Lakehouse architecture.
If you are only trying to build the backend (BE) for a normal StarRocks cluster, you should use:
bash
./build.sh --be --enable-shared-data -j4
If you specifically need the format-lib but don't need Cloud-Native support inside that library, removing --enable-shared-data may also bypass the problematic code path.
Summary: Stick with the 4.1.3 environment but apply the #include fix. If you absolutely cannot modify the code, try starrocks/dev-env-ubuntu:3.5-latest as a fallback.Kevin Cai
10/01/2026, 3:38 AM