Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#9522 closed bug (fixed)

[userlandFSServer] build failure with Haiku GCC 4

Reported by: mmadia Owned by: nobody
Priority: normal Milestone: R1
Component: Build System Version: R1/Development
Keywords: Cc:
Blocked By: Blocking: #9559
Platform: All

Description

This was briefly mentioned on the mailing list. Here's the ouput of building userlandfs_server for x86_32 GCC 4 from within hrev45285-gcc2h

/generated/x86gcc4> jam -q userlandfs_server
...patience...
...found 7682 target(s)...
...updating 19 target(s)...
C++ /generated/x86gcc4/objects/haiku/x86/release/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.o 
/use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.cpp: In member function 'status_t UserlandFS::UserlandFSServer::_Announce(const char*, port_id)':
/use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.cpp:173:63: error: array subscript is above array bounds [-Werror=array-bounds]
cc1plus: all warnings being treated as errors

/boot/develop/abi/x86/gcc4/tools/current/bin/gcc -c "/use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.cpp" -O2 -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar -pipe -fno-strict-aliasing -nostdinc -Wno-deprecated -march=pentium -D_ZETA_USING_DEPRECATED_API_=1 -D_ZETA_TS_FIND_DIR_=1 -Werror -Wno-error=uninitialized -Wno-unused-but-set-variable -DUSER=1 -DDEBUG_APP=\"userlandfs_server\" -DBUILDING_USERLAND_FS_SERVER=1 -D__HAIKU__ -DHAIKU_DISTRO_COMPATIBILITY_DEFAULT -D__INTEL__ -DARCH_x86 -DBOOT_ARCHIVE_IMAGE_OFFSET=300 -DB_USE_BUILTIN_ATOMIC_FUNCTIONS -DHAIKU_INCLUDE_PATENTED_CODE=0 -DHAIKU_TARGET_PLATFORM_HAIKU -iquote /use-the-source/haiku/build/user_config_headers -iquote /use-the-source/haiku/build/config_headers -iquote /use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/server -iquote /generated/x86gcc4/objects/common/add-ons/kernel/file_systems/userlandfs/server -iquote /generated/x86gcc4/objects/haiku_host/x86/common/add-ons/kernel/file_systems/userlandfs/server -iquote /generated/x86gcc4/objects/haiku/x86/common/add-ons/kernel/file_systems/userlandfs/server -iquote /use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/private -iquote /use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/shared -iquote /use-the-source/haiku/headers/private/userlandfs/private -iquote /use-the-source/haiku/headers/private/userlandfs/shared -I /use-the-source/haiku/headers/private/userlandfs -I /use-the-source/haiku/headers/private/. -I /use-the-source/haiku/headers/private/kernel -I /use-the-source/haiku/headers/private/libroot -I /use-the-source/haiku/headers/private/shared -I /use-the-source/haiku/headers/private/kernel/boot/platform/bios_ia32 -I /use-the-source/haiku/headers/private/kernel/arch/x86 -I /generated/x86gcc4/objects/haiku/x86/common/system/kernel -I /use-the-source/haiku/headers/private/. -I /use-the-source/haiku/headers/private/system -I /use-the-source/haiku/headers/private/system/arch/x86 -I /use-the-source/haiku/headers/private/libroot -I /use-the-source/haiku/headers/private/shared -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/../../../../include/c++/4.6.3 -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/../../../../include/c++/4.6.3/i586-pc-haiku -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/../../../../include/c++/4.6.3/backward -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/../../../../include/c++/4.6.3/ext -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/include -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/include-fixed -I /use-the-source/haiku/headers -I /use-the-source/haiku/headers/posix -I /use-the-source/haiku/headers/glibc -I /use-the-source/haiku/headers/os -I /use-the-source/haiku/headers/os/add-ons -I /use-the-source/haiku/headers/os/add-ons/file_system -I /use-the-source/haiku/headers/os/add-ons/graphics -I /use-the-source/haiku/headers/os/add-ons/input_server -I /use-the-source/haiku/headers/os/add-ons/registrar -I /use-the-source/haiku/headers/os/add-ons/screen_saver -I /use-the-source/haiku/headers/os/add-ons/tracker -I /use-the-source/haiku/headers/os/app -I /use-the-source/haiku/headers/os/device -I /use-the-source/haiku/headers/os/drivers -I /use-the-source/haiku/headers/os/game -I /use-the-source/haiku/headers/os/interface -I /use-the-source/haiku/headers/os/kernel -I /use-the-source/haiku/headers/os/locale -I /use-the-source/haiku/headers/os/media -I /use-the-source/haiku/headers/os/mail -I /use-the-source/haiku/headers/os/midi -I /use-the-source/haiku/headers/os/midi2 -I /use-the-source/haiku/headers/os/net -I /use-the-source/haiku/headers/os/opengl -I /use-the-source/haiku/headers/os/storage -I /use-the-source/haiku/headers/os/support -I /use-the-source/haiku/headers/os/translation -I /use-the-source/haiku/headers/private/. -o "/generated/x86gcc4/objects/haiku/x86/release/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.o" ;

...failed C++ /generated/x86gcc4/objects/haiku/x86/release/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.o ...

BUILD FAILURE:
...failed updating 1 target(s)...
...skipped 1 target(s)...
/generated/x86gcc4> 

Attachments (1)

userlandfs_disable_werror.diff (640 bytes ) - added by umccullough 12 years ago.
Should disable werror on userlandfs

Download all attachments as: .zip

Change History (16)

comment:1 by anevilyak, 12 years ago

Component: Add-OnsFile Systems/UserlandFS
Owner: changed from nobody to bonefish
Status: newassigned

comment:2 by bonefish, 12 years ago

Owner: changed from bonefish to nobody

Disable the useless warnings?

in reply to:  2 comment:3 by leavengood, 12 years ago

Replying to bonefish:

Disable the useless warnings?

That was my thought since I don't see what is wrong with this code. It seems silly having to work around a compiler being stupid.

comment:4 by umccullough, 12 years ago

Blocking: 9559 added

(In #9559) Duplicate of #9522

comment:5 by mounty, 12 years ago

I don't get this. Why are we indexing info->portInfos? It is of class Address which doesn't define operator [] and isn't an array.

in reply to:  5 comment:6 by anevilyak, 12 years ago

Replying to mounty:

I don't get this. Why are we indexing info->portInfos? It is of class Address which doesn't define operator [] and isn't an array.

Actually it is, c.f. http://haiku.it.su.se:8180/source/xref/headers/private/userlandfs/private/UserlandFSDefs.h#fs_init_info

gcc apparently gets confused by the use of the flexible array member in this instance. The fix would simply be to disable that particular warning since it's yielding false positives in a number of situations (and was only introduced in the latest version of gcc).

comment:7 by pdziepak, 12 years ago

+1 for explicitly and globally disabling -Warray-bounds. Let Coverity do the static analysis and GCC do the compiling. Moreover, since it is not enabled by default when not compiling under Haiku buildbot won't catch any future build failures and it would become a recurring problem.

However, if we want to be very strict the standard does not allow arrays of length 0 (C++03 8.3.4/1).

comment:8 by mounty, 12 years ago

Sorry; I was looking at the wrong declaration (obviously).

It seems to me that rather than omit a useful compiler warning (which has found real bugs; see #9486) we add an inline function to spoof the compiler in this rare case:

struct fs_init_info {
    FSCapabilities capabilities;
    client_fs_type clientFSType;
    int32          portInfoCount;
    Port::Info     portInfos[0];
    Port::Info * portInformation () { return portInfos; }
};

or maybe, to satisfy C++03 8.3.4/1 as mentioned above:

struct fs_init_info {
    FSCapabilities capabilities;
    client_fs_type clientFSType;
    int32          portInfoCount;
    class { }      infoAlign;
    Port::Info * portInfos () { return reinterpret_cast<Port::Info *>(&infoAlign); }
};

I do not see the point in ignoring information that the compiler is offering.

Last edited 12 years ago by mounty (previous) (diff)

comment:9 by pdziepak, 12 years ago

Out of 3 build failures caused by -Warray-bounds only one was not a false positive and it was already found by Coverity anyway.

Value range propagation is a simple static analysis which is performed only in translation unit scope. Therefore it never has complete information. It is not a problem when performing an optimization (although it also has caused problems by optimizing out too much, but that was very specific case). It is a problem when GCC tries to be a static analysis tool too hard and in a result warnings are reported despite the fact the code is correct.

It is really necessary to have complete information about the source code in order to reliably perform such analysis and that is what Coverity is for.

Last edited 12 years ago by pdziepak (previous) (diff)

comment:10 by mounty, 12 years ago

OK, we've all made our points and I accept that the consensus is to remove the warning. I disagree, but the most important thing for me is to be able to build Haiku again.

in reply to:  10 comment:11 by umccullough, 12 years ago

Replying to mounty:

OK, we've all made our points and I accept that the consensus is to remove the warning. I disagree, but the most important thing for me is to be able to build Haiku again.

If you're solely concerned about whether you can compile Haiku again, it should be a trivial temporary fix to just disable the "warnings-as-errors" for that particular subdirectory. I'll attach a patch that should do it for you.

by umccullough, 12 years ago

Should disable werror on userlandfs

comment:12 by mounty, 12 years ago

Great, thanks! Building again. Presumably this change will be committed to the repository at some stage?

The new Haiku builds alright but goes to KDL on boot. Hmm. Anyway, that is irrelevant to this ticket.

in reply to:  12 ; comment:13 by bonefish, 12 years ago

Replying to mounty:

Great, thanks! Building again. Presumably this change will be committed to the repository at some stage?

No, the warning should be disabled instead, i.e. -Wno-array-bounds needs to be added to the compiler flags instead.

in reply to:  13 comment:14 by anevilyak, 12 years ago

Component: File Systems/UserlandFSBuild System
Resolution: fixed
Status: assignedclosed

Replying to bonefish:

No, the warning should be disabled instead, i.e. -Wno-array-bounds needs to be added to the compiler flags instead.

Did so in hrev45405.

in reply to:  12 comment:15 by siarzhuk, 12 years ago

Replying to mounty:

The new Haiku builds alright but goes to KDL on boot. Hmm. Anyway, that is irrelevant to this ticket.

Wrong. ;-) Looks like you have trapped into this:

http://www.freelists.org/post/haiku-development/hrev45320-Yet-another-nonobvious-effect-of-ftreevrp-optimization

Starting hrev45320 GCC4 builds are broken and non-functional. :-D

Note: See TracTickets for help on using tickets.