[SERVER-8130] textSearchEnabled:false does not prevent creation of text index on some platforms Created: 09/Jan/13  Updated: 11/Jul/16  Resolved: 24/Jan/13

Status: Closed
Project: Core Server
Component/s: Text Search
Affects Version/s: None
Fix Version/s: 2.4.0-rc0

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: J Rassi
Resolution: Done Votes: 0
Labels: stringdata-use-after-free
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File fts_enable_flag.js    
Operating System: Windows
Participants:

 Description   

Windows (e.g. ec2-run-instances ami-a442fdcd -t m1.large):

C:\mongo\mongodb-win32-x86_64-2013-01-09\bin>mongo.exe
MongoDB shell version: 2.3.2-pre-
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
Server has startup warnings:
Wed Jan 09 22:03:45.435 [initandlisten]
Wed Jan 09 22:03:45.436 [initandlisten] ** NOTE: This is a development version (
2.3.2-pre-) of MongoDB.
Wed Jan 09 22:03:45.436 [initandlisten] **       Not recommended for production.
 
Wed Jan 09 22:03:45.436 [initandlisten]
> db.foo.ensureIndex({a:"text"})
> db.foo.getIndexes()
[
        {
                "v" : 1,
                "key" : {
                        "_id" : 1
                },
                "ns" : "test.foo",
                "name" : "_id_"
        },
        {
                "v" : 0,
                "key" : {
                        "_fts" : "text",
                        "_ftsx" : 1
                },
                "ns" : "test.foo",
                "name" : "a_text",
                "weights" : {
                        "a" : 1
                },
                "default_language" : "english",
                "language_override" : "language"
        }
]
>

But works as expected on OSX:

$ mongodb-osx-x86_64-2013-01-09/bin/mongod --fork --logpath /dev/null
about to fork child process, waiting until server is ready for connections.
forked process: 41171
all output going to: /dev/null
child process started successfully, parent exiting
$ mongodb-osx-x86_64-2013-01-09/bin/mongo
MongoDB shell version: 2.3.2-pre-
connecting to: test
Server has startup warnings: 
Wed Jan  9 16:58:40.693 [initandlisten] 
Wed Jan  9 16:58:40.694 [initandlisten] ** NOTE: This is a development version (2.3.2-pre-) of MongoDB.
Wed Jan  9 16:58:40.694 [initandlisten] **       Not recommended for production.
Wed Jan  9 16:58:40.694 [initandlisten] 
> db.foo.ensureIndex({a:"text"})
{
	"err" : "text search not enabled",
	"code" : 16633,
	"n" : 0,
	"connectionId" : 1,
	"ok" : 1
}
>

Culprit, presumably:

         BSONObj FTSIndexPlugin::adjustIndexSpec( const BSONObj& spec ) const {
             StringData desc  = cc().desc();
             if ( desc.find( "conn" ) == 0 ) {
                 // this is to make sure we only complain for users
                 // if you do get a text index created an a primary
                 // want it to index on the secondary as well
                 massert( 16633, "text search not enabled", isTextSearchEnabled() );
             }
             return FTSSpec::fixSpec( spec );
         }



 Comments   
Comment by auto [ 24/Jan/13 ]

Author:

{u'date': u'2013-01-24T17:47:40Z', u'email': u'rassi@10gen.com', u'name': u'Jason Rassi'}

Message: SERVER-8130 Fix invalid access in textSearchEnabled check

Bug introduced in fts_index.cpp, FTSIndexPlugin::adjustIndexSpec()
(not changed by diff):

69| StringData desc = cc().desc();

Previously, Client::desc() returned std::string, so desc._data
became a dangling pointer to destroyed temporary cc().desc().
Resolved by changing return type of Client::desc() to StringData.
Branch: master
https://github.com/mongodb/mongo/commit/6cf5e6d6318f0f9f932f02337e33b8a7e0b5c76b

Comment by J Rassi [ 09/Jan/13 ]

Broken test case attached.

Comment by auto [ 09/Jan/13 ]

Author:

{u'date': u'2013-01-09T23:02:52Z', u'email': u'rassi@10gen.com', u'name': u'Jason Rassi'}

Message: Revert "SERVER-8130 add test case for textSearchEnabled flag"

This reverts commit 19ab4ba71c5793878d6588d6c9d6eb6fee26c6d9.
Branch: master
https://github.com/mongodb/mongo/commit/17cc56d647f8edb44ea2d130850bfb037cbd672f

Comment by auto [ 09/Jan/13 ]

Author:

{u'date': u'2013-01-09T22:48:33Z', u'email': u'rassi@10gen.com', u'name': u'Jason Rassi'}

Message: SERVER-8130 add test case for textSearchEnabled flag
Branch: master
https://github.com/mongodb/mongo/commit/19ab4ba71c5793878d6588d6c9d6eb6fee26c6d9

Generated at Thu Feb 08 03:16:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.