Skip to content

Conversation

debasishbsws
Copy link
Member

… stict dependency on older protobuf rebuildig this so that it can pickup the latest grpc which depnds on the latest protobuf

… stict dependency on older protobuf rebuildig this so that it can pickup the latest grpc which depnds on the latest protobuf

Signed-off-by: Debasish Biswas <debasishbsws.dev@gmail.com>
@debasishbsws debasishbsws enabled auto-merge (squash) June 2, 2025 17:11
imjasonh
imjasonh previously approved these changes Jun 2, 2025
Copy link
Contributor

octo-sts bot commented Jun 2, 2025

🛑 Build Failed: Compilation

initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (13 chars into 12 available) [-Werror=unterminated-string-initialization]

Build Details

Category Details
Build System make/gcc
Failure Point src/http/v2/ngx_http_v2_filter_module.c:121

Root Cause Analysis 🔍

The string literal is being used to initialize an array of 'unsigned char', but the string is 13 bytes long (including the null terminator) while the destination array only has space for 12 bytes. Since the compiler flag -Werror is enabled, this warning is treated as an error, causing the build to fail.


🔍 Build failure fix suggestions

Found similar build failures that have been fixed in the past and analyzed them to suggest a fix:

Suggested Changes

File: src/http/v2/ngx_http_v2_filter_module.c

  • modification at line 121 (Array size declaration)
    Original:
static u_char  ngx_http_v2_pad_frame_header[12] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PADDED
};

Replacement:

static u_char  ngx_http_v2_pad_frame_header[13] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PADDED
};

File: src/http/v2/ngx_http_v2_filter_module.c

  • modification at line 121 (Array declaration with nonstring attribute)
    Original:
static u_char  ngx_http_v2_pad_frame_header[12] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PADDED
};

Replacement:

static u_char  ngx_http_v2_pad_frame_header[12] __attribute__((nonstring)) = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PADDED
};

Click to expand fix analysis

Analysis

The build failure is happening in src/http/v2/ngx_http_v2_filter_module.c:121 due to a string initializer for an array of 'unsigned char' being 13 bytes long (including the null terminator) while the destination array only has space for 12 bytes. This is causing a compiler error because -Werror treats warnings as errors.

In the nginx code, there's likely a fixed-size array declaration with a size of 12 bytes, but the string literal used to initialize it is actually 13 bytes (12 characters plus the null terminator). Since this is in the HTTP/2 filter module, it's probably a constant string or protocol identifier.

The error message specifically mentions "initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute" which indicates that the compiler is detecting a string that won't fit properly in the destination array.

Click to expand fix explanation

Explanation

The error occurs because the compiler is detecting a string initialization where the destination array is not large enough to hold the null terminator. There are two potential fixes:

  1. Increase the array size: Change the array size from 12 to 13 bytes to accommodate the null terminator. This ensures there's enough space for the string including its null terminator.

  2. Add the nonstring attribute: Add the __attribute__((nonstring)) attribute to the array declaration to explicitly tell the compiler that this array is not meant to be treated as a null-terminated string. This informs the compiler that the null terminator truncation is intentional and not an error.

Either approach should resolve the error, but the first one (increasing the array size) is often preferred for clarity and to avoid potential issues with string handling functions that might assume null termination. The second approach (using the nonstring attribute) is more appropriate if the array is truly not meant to be treated as a string and its exact size is important.

The issue is likely that NGINX is initializing a fixed-size buffer for HTTP/2 frame headers, but the size doesn't account for the null terminator that C automatically adds to string literals. Since this appears to be protocol-related data used in binary format rather than as a C string, the nonstring attribute would be appropriate, but increasing the array size is the safer approach if the additional byte doesn't affect protocol compatibility.

Click to expand alternative approaches

Alternative Approaches

  • Instead of modifying the array size or adding the nonstring attribute, you could change the initialization syntax to explicitly list all bytes without using a string literal: static u_char ngx_http_v2_pad_frame_header[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PADDED};
  • If this array is used in a context where null termination is expected but not required, you could use a compiler flag to suppress just this specific warning rather than modifying the code: -Wno-error=unterminated-string-initialization. However, this approach is less preferred as it masks the issue rather than addressing it.
  • If the data doesn't need to be static, you could initialize it at runtime where these compiler warnings don't apply: u_char ngx_http_v2_pad_frame_header[12]; memcpy(ngx_http_v2_pad_frame_header, "\0\0\0\0\0\0\0\0\0\0\0PADDED", 12);

Was this comment helpful? Please use 👍 or 👎 reactions on this comment.

@octo-sts octo-sts bot added the ai/skip-comment Stop AI from commenting on PR label Jun 2, 2025
Signed-off-by: Debasish Biswas <debasishbsws.dev@gmail.com>
@debasishbsws
Copy link
Member Author

Not sure avoiding that error is a good idea or not.

@kwmonroe
Copy link
Member

kwmonroe commented Jun 2, 2025

Not sure avoiding that error is a good idea or not.

fwiw, nginx/unit did something similar to disable the gcc 15 warning while working on a compatible refactor.

For the current protobuf errors, it looks like we need to bring opentelemetry-cpp-dev's protobuf up from 5.29.4 to jive with protobuf-dev's 5.29.5.

@octo-sts octo-sts bot added the bincapz/pass bincapz/pass Bincapz (aka. malcontent) scan didn't detect any CRITICALs on the scanned packages. label Jun 3, 2025
@debasishbsws debasishbsws merged commit 089bd67 into wolfi-dev:main Jun 3, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/skip-comment Stop AI from commenting on PR bincapz/pass bincapz/pass Bincapz (aka. malcontent) scan didn't detect any CRITICALs on the scanned packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants