Bug 1181882

Summary: GCC 11: spirv-tools package fails
Product: [openSUSE] openSUSE Tumbleweed Reporter: Martin Liška <martin.liska>
Component: BasesystemAssignee: Jan Engelhardt <jengelh>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: ismail
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 1181859    

Description Martin Liška 2021-02-06 11:23:11 UTC
The package fails here:
https://build.opensuse.org/package/live_build_log/openSUSE:Factory:Staging:Gcc7/spirv-tools/standard/x86_64

due to:
[   18s] In function 'char* strncpy(char*, const char*, size_t)',
[   18s]     inlined from 'spv_diagnostic_t* spvDiagnosticCreate(spv_position, const char*)' at /home/abuild/rpmbuild/BUILD/SPIRV-Tools-2020.6/source/diagnostic.cpp:40:10:
[   18s] /usr/include/bits/string_fortified.h:106:34: error: 'char* __builtin_strncpy(char*, const char*, long unsigned int)' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
[   18s]   106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
[   18s]       |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[   18s] /home/abuild/rpmbuild/BUILD/SPIRV-Tools-2020.6/source/diagnostic.cpp: In function 'spv_diagnostic_t* spvDiagnosticCreate(spv_position, const char*)':
[   18s] /home/abuild/rpmbuild/BUILD/SPIRV-Tools-2020.6/source/diagnostic.cpp:31:25: note: length computed here
[   18s]    31 |   size_t length = strlen(message) + 1;
[   18s]       |                   ~~~~~~^~~~~~~~~
[   18s] cc1plus: all warnings being treated as errors
Comment 1 Ismail Dönmez 2021-02-10 12:13:28 UTC
(In reply to Martin Liška from comment #0)
> The package fails here:
> https://build.opensuse.org/package/live_build_log/openSUSE:Factory:Staging:
> Gcc7/spirv-tools/standard/x86_64
> 
> due to:
> [   18s] In function 'char* strncpy(char*, const char*, size_t)',
> [   18s]     inlined from 'spv_diagnostic_t*
> spvDiagnosticCreate(spv_position, const char*)' at
> /home/abuild/rpmbuild/BUILD/SPIRV-Tools-2020.6/source/diagnostic.cpp:40:10:
> [   18s] /usr/include/bits/string_fortified.h:106:34: error: 'char*
> __builtin_strncpy(char*, const char*, long unsigned int)' specified bound
> depends on the length of the source argument [-Werror=stringop-overflow=]
> [   18s]   106 |   return __builtin___strncpy_chk (__dest, __src, __len,
> __bos (__dest));
> [   18s]       |         
> ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [   18s]
> /home/abuild/rpmbuild/BUILD/SPIRV-Tools-2020.6/source/diagnostic.cpp: In
> function 'spv_diagnostic_t* spvDiagnosticCreate(spv_position, const char*)':
> [   18s]
> /home/abuild/rpmbuild/BUILD/SPIRV-Tools-2020.6/source/diagnostic.cpp:31:25:
> note: length computed here
> [   18s]    31 |   size_t length = strlen(message) + 1;
> [   18s]       |                   ~~~~~~^~~~~~~~~
> [   18s] cc1plus: all warnings being treated as errors

strncpy works as intended here, this is a gcc bug https://gcc.gnu.org/bugzilla//show_bug.cgi?id=88059
Comment 2 OBSbugzilla Bot 2021-02-10 12:30:07 UTC
This is an autogenerated message for OBS integration:
This bug (1181882) was mentioned in
https://build.opensuse.org/request/show/870832 Factory / spirv-tools
Comment 3 Martin Liška 2021-02-10 13:01:58 UTC
> 
> strncpy works as intended here, this is a gcc bug
> https://gcc.gnu.org/bugzilla//show_bug.cgi?id=88059

Yes, I must admit the warning has quite some false positivies. In this case,
length is used both for allocation of dest argument (which is strlen of message + 1).
Thank you for the workaround.
Comment 4 Martin Liška 2021-02-10 13:03:36 UTC
Fixed in devel project.
Comment 5 Ismail Dönmez 2021-02-10 13:04:15 UTC
(In reply to Martin Liška from comment #3)
> > 
> > strncpy works as intended here, this is a gcc bug
> > https://gcc.gnu.org/bugzilla//show_bug.cgi?id=88059
> 
> Yes, I must admit the warning has quite some false positivies. In this case,
> length is used both for allocation of dest argument (which is strlen of
> message + 1).
> Thank you for the workaround.

s/strncpy/strcpy is a bad workaround, though. Removing -Werror should be enough.
Comment 6 OBSbugzilla Bot 2021-02-10 16:30:06 UTC
This is an autogenerated message for OBS integration:
This bug (1181882) was mentioned in
https://build.opensuse.org/request/show/870954 Factory / spirv-tools
Comment 7 Jan Engelhardt 2021-03-01 09:29:51 UTC
Patch backed out.
Comment 8 Martin Liška 2021-03-18 13:49:34 UTC
The issue still remains, can you please take a look?
Comment 9 OBSbugzilla Bot 2021-03-18 15:10:07 UTC
This is an autogenerated message for OBS integration:
This bug (1181882) was mentioned in
https://build.opensuse.org/request/show/879908 Factory / spirv-tools
Comment 10 Martin Liška 2021-03-18 15:13:46 UTC
Fixed in devel project again.