[CDRIVER-3094] bson_iter_binary doesn't work on a Windows build Created: 23/Apr/19  Updated: 31/Dec/19  Resolved: 31/Dec/19

Status: Closed
Project: C Driver
Component/s: libbson
Affects Version/s: 1.14.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Felipe Noronha Tavares Assignee: Kevin Albertson
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Xeon(R) CPU E5-2697 v3 @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, haswell)



 Description   

I'm running an appveyor script that tests libbson and libmongoc on various platforms.
Everything works, including libmongoc API, except `bson_iter_binary`.

The log below is not very helpful, since by the time `bson_iter_binary` is called, the thread just panics and no output or error trace is printed.

In this case, libbson and libmongoc were built with appveyor's Visual Studio 2015 image.

```
Build started
git clone -q --branch=fn/windows https://github.com/felipenoris/Mongoc.jl.git C:\projects\mongoc-jl
git checkout -qf 176c69b415380ef89aad9dfdcc5f770dcec28b9f
Running Install scripts
iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
Installing Julia...
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Xeon(R) CPU E5-2697 v3 @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, haswell)
Environment:
JULIA_PROJECT = @.
Starting MongoDB
echo "%JL_BUILD_SCRIPT%"
"using Pkg; Pkg.build()"
C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
Cloning default registries into C:\Users\appveyor\.julia\registries
Cloning registry General from "https://github.com/JuliaRegistries/General.git"
Installed BinaryProvider ─ v0.5.3
Building Mongoc → `C:\projects\mongoc-jl\deps\build.log`
Resolving package versions...
echo "%JL_TEST_SCRIPT%"
"using Pkg; Pkg.test(coverage=true)"
C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
Testing Mongoc
Resolving package versions...
┌ Info: Testing for platform:
└ platform_key_abi() = Windows(:x86_64, compiler_abi=CompilerABI(:gcc4, :cxx11))
┌ Warning: Failed to remove test file C:\projects\mongoc-jl\test\data.bson: unlink: resource busy or locked (EBUSY)
└ @ Main C:\projects\mongoc-jl\test\bson_tests.jl:327
Test Summary: | Pass Total
BSON | 10097 10097
Server Mongo Version: 4.0.1
ERROR: Package Mongoc errored during testing
Stacktrace:
[1] pkgerror(::String, ::Vararg

{String,N}

where N) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Pkg\src\Types.jl:120
[2] #test#65(::Bool, ::Function, ::Pkg.Types.Context, ::Array

{Pkg.Types.PackageSpec,1}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Pkg\src\Operations.jl:1357
[3] #test at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Pkg\src\API.jl:0 [inlined]
[4] #test#42(::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}

) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Pkg\src\API.jl:273
[5] #test#41 at .\none:0 [inlined]
[6] #test at .\none:0 [inlined]
[7] #test#38 at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Pkg\src\API.jl:252 [inlined]
[8] (::getfield(Pkg.API, Symbol("#kw##test")))(::NamedTuple{(:coverage,),Tuple{Bool}}, ::typeof(Pkg.API.test)) at .\none:0
[9] top-level scope at none:0
```

Ref:



 Comments   
Comment by Kevin Albertson [ 31/Dec/19 ]

Hi felipenoris, looking at the linked repos, I assume this skipped test is the producer of that stack trace:
https://github.com/felipenoris/Mongoc.jl/blob/7971830f797643c202404f3cec62eaec4c9052ee/test/mongodb_tests.jl#L163-L179

I'm not familiar with Julia or how it integrates with C libraries, so I'm taking a long shot here, but perhaps the call to bson_iter_binary is missing the subtype argument here: https://github.com/felipenoris/Mongoc.jl/blob/7971830f797643c202404f3cec62eaec4c9052ee/src/bson.jl#L520
Compare that with libbson's bson_iter_binary: http://mongoc.org/libbson/current/bson_iter_binary.html with the subtype as the second argument.

If you are able to provide more info and this indicates a bug with libbson feel free to re-open and we'll investigate further. But if this is Julia specific, we likely cannot provide much assistance.

Comment by Kevin Albertson [ 06/May/19 ]

Hi felipenoris, thanks for the report! Are you able to reproduce this with a C driver test outside of the Julia wrapper?

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