[CDRIVER-1486] The library exports "TRACE" as an un-prefixed global symbol (define) Created: 23/Aug/16  Updated: 19/Oct/16  Resolved: 30/Aug/16

Status: Closed
Project: C Driver
Component/s: Build
Affects Version/s: 1.4.0
Fix Version/s: 1.5.0

Type: Bug Priority: Major - P3
Reporter: Derick Rethans Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by PHPC-773 Update MONGOC_TRACE to MONGOC_ENABLE_... Closed
Related
is related to CDRIVER-1408 Include mongoc-trace.h from mongoc.h ... Closed

 Description   

The driver defines "TRACE", without prefixing it with a library specific prefix. This causes issues with HHVM (at least, 3.13.1), as it does the same.

I am now getting the following compile errors:

derick@whisky:~/dev/php/derickr-mongo-hhvm-driver $ make
[  0%] Building CXX object CMakeFiles/mongodb.dir/mongodb.cpp.o
In file included from /home/derick/dev/php/derickr-mongo-hhvm-driver/src/MongoDB/Driver/../../../libmongoc/src/mongoc/mongoc.h:54:0,
                 from /home/derick/dev/php/derickr-mongo-hhvm-driver/src/MongoDB/Driver/BulkWrite.h:21,
                 from /home/derick/dev/php/derickr-mongo-hhvm-driver/mongodb.cpp:21:
/home/derick/dev/php/derickr-mongo-hhvm-driver/src/MongoDB/Driver/../../../libmongoc/src/mongoc/mongoc-trace.h:42:0: warning: "TRACE" redefined
 #define TRACE(msg,...)
 ^
In file included from /usr/local/hhvm/3.13.1/include/hphp/runtime/base/memory-manager.h:31:0,
                 from /usr/local/hhvm/3.13.1/include/hphp/runtime/base/array-data.h:25,
                 from /usr/local/hhvm/3.13.1/include/hphp/runtime/base/type-array.h:20,
                 from /usr/local/hhvm/3.13.1/include/hphp/runtime/base/exceptions.h:28,
                 from /usr/local/hhvm/3.13.1/include/hphp/runtime/base/string-data.h:30,
                 from /usr/local/hhvm/3.13.1/include/hphp/runtime/base/type-string.h:22,
                 from /usr/local/hhvm/3.13.1/include/hphp/runtime/base/debuggable.h:19,
                 from /usr/local/hhvm/3.13.1/include/hphp/runtime/ext/extension.h:21,
                 from /home/derick/dev/php/derickr-mongo-hhvm-driver/mongodb.cpp:17:
/usr/local/hhvm/3.13.1/include/hphp/util/trace.h:386:0: note: this is the location of the previous definition
 #define TRACE(...)        do { } while (0)
 ^
In file included from /home/derick/dev/php/derickr-mongo-hhvm-driver/mongodb.cpp:34:0:
/home/derick/dev/php/derickr-mongo-hhvm-driver/src/MongoDB/BSON/Decimal128.h:34:3: error: ‘bson_decimal128_t’ does not name a type
   bson_decimal128_t m_decimal;
   ^
CMakeFiles/mongodb.dir/build.make:62: recipe for target 'CMakeFiles/mongodb.dir/mongodb.cpp.o' failed
make[2]: *** [CMakeFiles/mongodb.dir/mongodb.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mongodb.dir/all' failed
make[1]: *** [CMakeFiles/mongodb.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

The driver should prefix this with something, as to prevent symbol clashes.

I also filed an issue for HHVM: https://github.com/facebook/hhvm/issues/7288



 Comments   
Comment by Githook User [ 30/Aug/16 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-1486: Rename mongoc-trace.h -> mongoc-trace-private.h
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/8e209e4af5ccff3920a012dd1da8ee8048197806

Comment by Hannes Magnusson [ 29/Aug/16 ]

maybe. I however don't want to be renaming them, that would defeat their purpose. I'd rather move tracing out of bleeding headers, but that would mean you would loose that functionality for your debugging, which isn't exactly a great outcome.

Comment by Jeremy Mikola [ 29/Aug/16 ]

I realize this was only an issue for derick due to the HHVM conflict; however, the libmongoc PR only addresses TRACE() macro. Aren't ENTRY(), RETURN(), and the other trace macros also candidates for prefixing?

Comment by Hannes Magnusson [ 23/Aug/16 ]

https://mongodbcr.appspot.com/87860002/

Comment by Hannes Magnusson [ 23/Aug/16 ]

We don't expect to be releasing 1.4.1.

Since this is an unexported macro, I think we can get away with straight rename.

Do note, jmikola that I will have to rename the define that includes that tracing functionality from MONGOC_TRACE to MONGOC_ENABLE_TRACE.
I think the PHP driver currently hardcodes -DMONGOC_TRACE

Comment by Derick Rethans [ 23/Aug/16 ]

I managed to prevent the clash with "#undef TRACE" in lots of places, so not as important now any more: https://github.com/mongodb/mongo-hhvm-driver/pull/123/commits/ae057f5a125d35b82762436a32ccbcf92b235c8d

Comment by Derick Rethans [ 23/Aug/16 ]

It currently "breaks" compilation (lots of warnings) for the HHVM driver, so I don't think it can wait until 1.5.0. I guess that's a BC break though, so perhaps it could be a flag?

Comment by Hannes Magnusson [ 23/Aug/16 ]

Makes sense. It really should be MONGOC_TRACE().
Never understood why it wasn't

Generated at Wed Feb 07 21:12:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.