[SERVER-68887] Can not build on the Ubuntu 22.04 LTS Created: 17/Aug/22  Updated: 29/Oct/23  Resolved: 08/Sep/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 6.0.1
Fix Version/s: 6.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Kane You Assignee: Juan Gu
Resolution: Fixed Votes: 0
Labels: compiler-warnings
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File config.log    
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

sudo apt install build-essential
sudo apt install libcurl4-openssl-dev
sudo apt install liblzma-dev
sudo apt install libssl-dev
python3 -m pip install -r etc/pip/compile-requirements.txt
python3 buildscripts/scons.py install-mongod
 

Participants:

 Description   

according to https://github.com/mongodb/mongo/blob/master/docs/building.md

 

the error report is:

 

```bash

Compiling build/59f4f0dd/mongo/db/exec/sbe/values/value_printer.o
In file included from build/59f4f0dd/mongo/base/error_codes.h:36,
                 from src/mongo/base/data_type.h:37,
                 from src/mongo/base/data_type_endian.h:35,
                 from src/mongo/db/exec/sbe/values/value.h:43,
                 from src/mongo/db/exec/sbe/values/value.cpp:32:
In constructor 'mongo::StringData::StringData(const char*)',
    inlined from 'mongo::sbe::value::BsonRegex::BsonRegex(const char*)' at src/mongo/db/exec/sbe/values/value.h:1230:15,
    inlined from 'mongo::sbe::value::BsonRegex mongo::sbe::value::getBsonRegexView(mongo::sbe::value::Value)' at src/mongo/db/exec/sbe/values/value.h:1243:44,
    inlined from 'std::pair<mongo::sbe::value::TypeTags, long unsigned int> mongo::sbe::value::compareValue(mongo::sbe::value::TypeTags, mongo::sbe::value::Value, mongo::sbe::value::TypeTags, mongo::sbe::value::Value, const mongo::StringData::ComparatorInterface*)' at src/mongo/db/exec/sbe/values/value.cpp:728:41:
src/mongo/base/string_data.h:82:68: error: 'size_t strlen(const char*)' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
   82 | ingData(const char* str) : StringData(str, str ? std::strlen(str) : 0) {}
      |                                                  ~~~~~~~~~~^~~~

In constructor 'mongo::StringData::StringData(const char*)',
    inlined from 'mongo::sbe::value::BsonRegex::BsonRegex(const char*)' at src/mongo/db/exec/sbe/values/value.h:1230:15,
    inlined from 'mongo::sbe::value::BsonRegex mongo::sbe::value::getBsonRegexView(mongo::sbe::value::Value)' at src/mongo/db/exec/sbe/values/value.h:1243:44,
    inlined from 'std::pair<mongo::sbe::value::TypeTags, long unsigned int> mongo::sbe::value::compareValue(mongo::sbe::value::TypeTags, mongo::sbe::value::Value, mongo::sbe::value::TypeTags, mongo::sbe::value::Value, const mongo::StringData::ComparatorInterface*)' at src/mongo/db/exec/sbe/values/value.cpp:727:41:
src/mongo/base/string_data.h:82:68: error: 'size_t strlen(const char*)' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
   82 | ingData(const char* str) : StringData(str, str ? std::strlen(str) : 0) {}
      |                                                  ~~~~~~~~~~^~~~

In constructor 'mongo::StringData::StringData(const char*)',
    inlined from 'mongo::sbe::value::BsonRegex::BsonRegex(const char*)' at src/mongo/db/exec/sbe/values/value.h:1230:15,
    inlined from 'mongo::sbe::value::BsonRegex mongo::sbe::value::getBsonRegexView(mongo::sbe::value::Value)' at src/mongo/db/exec/sbe/values/value.h:1243:44,
    inlined from 'std::pair<mongo::sbe::value::TypeTags, long unsigned int> mongo::sbe::value::compareValue(mongo::sbe::value::TypeTags, mongo::sbe::value::Value, mongo::sbe::value::TypeTags, mongo::sbe::value::Value, const mongo::StringData::ComparatorInterface*)' at src/mongo/db/exec/sbe/values/value.cpp:728:41:
src/mongo/base/string_data.h:82:68: error: 'size_t strlen(const char*)' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
   82 | ingData(const char* str) : StringData(str, str ? std::strlen(str) : 0) {}
      |                                                  ~~~~~~~~~~^~~~

cc1plus: all warnings being treated as errors
scons: *** [build/59f4f0dd/mongo/db/exec/sbe/values/value.o] Error 1
scons: building terminated because of errors.
build/59f4f0dd/mongo/db/exec/sbe/values/value.o failed: Error 1

```
 



 Comments   
Comment by Githook User [ 08/Sep/22 ]

Author:

{'name': 'Ubuntu', 'email': 'ubuntu@ip-10-0-4-192.ec2.internal'}

Message: SERVER-68887 stringop-overread issue Can not build on the Ubuntu 22.04 LTS
Branch: master
https://github.com/mongodb/mongo/commit/219990f17695b0ea4695f827a42a18e012b1e9cf

Comment by Chris Kelly [ 18/Aug/22 ]

For C++ compilers that are newer than the supported version, the compiler may issue new warnings that cause MongoDB to fail to build since the build system treats compiler warnings as errors.

If you try this, it may build:

 python3 buildscripts/scons.py install-mongod --disable-warnings-as-errors

I'll pass this issue along to the relevant team to take a look at these warnings though. Thanks for your report!

Christopher

Comment by Kane You [ 18/Aug/22 ]

config.log

Comment by Kane You [ 17/Aug/22 ]

gcc and g++ version is 11.2-1 

from the ubuntu official repo

Comment by Ryan Egesdahl (Inactive) [ 17/Aug/22 ]

diracsvip@gmail.com Which compiler are you using and which version of it? Also, would you please attach the build/scons/config.log from the build to this ticket? (It should be located inside the source directory where you ran those commands.)

Generated at Thu Feb 08 06:12:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.