tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: QString and ctype(3)
On Tue, Jul 01, 2025 at 06:11:25PM -0400, Greg Troxel wrote:
> The qgis build crashes on NetBSD current with:
>
> FAILED: src/crssync/CMakeFiles/synccrsdb /n0/tmp/work/geography/qgis/work/qgis-3.40.7/cmake-pkgsrc-build/src/crssync/CMakeFiles/synccrsdb
> cd /n0/tmp/work/geography/qgis/work/qgis-3.40.7/cmake-pkgsrc-build/src/crssync && env LD_LIBRARY_PATH=/n0/tmp/work/geography/qgis/work/qgis-3.40.7/cmake-pkgsrc-build/output/bin/../lib DYLD_LIBRARY_PATH=/n0/tmp/work/geography/qgis/work/qgis-3.40.7/cmake-pkgsrc-build/output/bin/../lib /n0/tmp/work/geography/qgis/work/qgis-3.40.7/cmake-pkgsrc-build/output/bin/crssync
> ctype(3) tolower: invalid input: -62
> ninja: build stopped: subcommand failed.
>
> and I think it's because of
>
> bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
> {
> if ( definition.isEmpty() )
> return false;
>
> QgsReadWriteLocker locker( *sCrsStringLock(), QgsReadWriteLocker::Read );
> if ( !sDisableStringCache )
> {
> QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = sStringCache()->constFind( definition );
> if ( crsIt != sStringCache()->constEnd() )
> {
> // found a match in the cache
> *this = crsIt.value();
> return d->mIsValid;
> }
> }
> locker.unlock();
>
> bool result = false;
> const thread_local QRegularExpression reCrsId( QStringLiteral( "^(epsg|esri|osgeo|ignf|ogc|nkg|zangi|iau_2015|iau2000|postgis|internal|user)\\:(\\w+)$" ), QRegularExpression::CaseInsensitiveOption );
> QRegularExpressionMatch match = reCrsId.match( definition );
> if ( match.capturedStart() == 0 )
> {
> QString authName = match.captured( 1 ).toLower();
> if ( authName == QLatin1String( "epsg" ) )
> {
> result = createFromOgcWmsCrs( definition );
> }
>
> Perhaps, because a QString is char, not unsigned char -- but that's
> guessing. But it may be some other toLower, not the one above.
>
> cppreference.com (not sure I should believe that) says .toLower is a
> horror show:
>
> https://en.cppreference.com/w/cpp/string/byte/tolower
>
>
>
> Is anyone else seeing issues with QT programs under NetBSD current?
Reading thru qt6 source, QUnicodeTables::convertCase() doesn't seem to
rely on ctype(3). Sure it's not one of the usages in qgis itself? They
look suspect, I think? I don't have a system running current to easily
test.
fwiw, I've tripped over ctype(3) breakage previously, too, most recently:
https://github.com/stixpjr/widelands/commit/755251e0d89d7b739645d1cafbf3351ae1ca74b8
The fact the ctype(3) API takes (int) args but has UB if called with
a value <-1 is just asking for trouble.
Cheers,
--
Paul Ripke
"Great minds discuss ideas, average minds discuss events, small minds
discuss people."
-- Disputed: Often attributed to Eleanor Roosevelt. 1948.
Home |
Main Index |
Thread Index |
Old Index