[CDRIVER-1220] Runtime Error: Assertion Failed Created: 04/May/16 Updated: 03/May/17 Resolved: 06/Jun/16 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libmongoc |
| Affects Version/s: | 1.3.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | David P [X] | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | driver | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
ArchLinux, NGINX, FastCGI, g++ |
||
| Description |
|
I switched from C driver to C++ driver and that resolved my issues. However, I do not see why the C driver shouldn't have worked. Since I'm using more than one DBMS I wanted to keep the libraries managing them under the same language binding and not all of them have competent C++ bindings. The runtime error is simply complaining about an assertion failing on command = BCON_NEW ("ping", BCON_INT32 (1)); call from the tutorial at http://api.mongodb.org/c/1.3.5/tutorial.html#connecting I had to change passing in "ping" to char ping[] = "ping"; and pass in the variable instead of the string literal to get it to compile. This tutorial was inserted in a bare fastcgi program. I compiled my program with the folllowing command: g++ main.cpp -lfcgi -lfcgi++ -lmongoc-1.0 -lbson-1.0 --std=c++14 |
| Comments |
| Comment by A. Jesse Jiryu Davis [ 06/Jun/16 ] | ||||||||||||||||||||||
|
I'm closing this for now; if you can reproduce the error with a minimal code example that I can compile, please reopen this ticket and we'll investigate. | ||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 08/May/16 ] | ||||||||||||||||||||||
|
I installed GCC 4.9 (for C++14 support) on Ubuntu and attempted a minimal reproduction of your issue. I can't reproduce the error:
The code compiles and works as expected using the BCON_NEW macro. If you build this minimal source file on your system, do you get the assertion or does it work? | ||||||||||||||||||||||
| Comment by David P [X] [ 07/May/16 ] | ||||||||||||||||||||||
|
When I use BCON_NEW() I get no errors. When I use bcon_new() I get the following error: Runtime Error Message: "mongoc_test: src/bson/bcon.c:789: bcon_append_ctx_va: Assertion `type == BCON_TYPE_UTF8' failed." Compile Command: g++ mongoc_test.cpp -o mongoc_test -I /usr/include/libbson-1.0 -I /usr/include/libmongoc-1.0 -lfcgi -lfcgi++ -lmongoc-1.0 -lbson-1.0 /**************************************************************************************/ #include <iostream> #include <bson.h> int main(void) { using namespace std; // Backup the stdio streambufs FCGX_Request request; mongoc_client_t *client; FCGX_Init(); mongoc_init(); char ping[] = "ping"; while (FCGX_Accept_r(&request) == 0) { fcgi_streambuf cin_fcgi_streambuf(request.in); fcgi_streambuf cout_fcgi_streambuf(request.out); fcgi_streambuf cerr_fcgi_streambuf(request.err); cin.rdbuf(&cin_fcgi_streambuf); cout.rdbuf(&cout_fcgi_streambuf); cerr.rdbuf(&cerr_fcgi_streambuf); } // restore stdio streambufs return 0; /******************************************************************************/ | ||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 05/May/16 ] | ||||||||||||||||||||||
|
Can I see your main.cpp, please, and the complete output from your program's execution? Is it possible to reproduce the failure with pure-C code compiled with GCC and no "--std" argument? I'm curious, since we're not yet testing and supporting standards beyond C99, and C++ circa 2003. |