# FoundationDB error code 4100 when trying to debug golang program under windows

**URL:** <https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361>\
**Category:** Using FoundationDB\
**Tags:** bindings\
**Created:** [September 25, 2020, 11:30am UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361 "2020-09-25T11:30:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![imukhin](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@imukhin](https://forums.foundationdb.org/u/imukhin)\
**Post date:** [September 25, 2020, 11:30am UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/1 "2020-09-25T11:30:34Z")

</div>

I tried to debug go program which uses go bindings to access FDB in delve (go debugger) and got the following error:  
`FoundationDB error code 4100 (An internal error occurred)`  
The 4100 error is returned by fdb\_setup\_network() C function.  
The same program runs without errors and successfully connects to FDB when launched without debugger.  
I use fdb client 6.2.25 for windows, go 1.15.2 (buth the same was for 1.13).

What may be the reason for such error and how to avoid it?

---

<div class="post-metadata">

**Author:** ![ajbeamon](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ajbeamon/32/13_2.png) [@ajbeamon](https://forums.foundationdb.org/u/ajbeamon)\
**Post date:** [September 25, 2020, 3:30pm UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/2 "2020-09-25T15:30:49Z")

</div>

Unfortunately, a failure in `fdb_setup_network` is probably early enough that you can’t get trace files, unless perhaps you are calling this function more than once.

I believe it is the case that internal errors should print out some extra details about the error to `stderr`. In particular, it should have a file and line number of the error as well as a backtrace. Do you get any of this output?

---

<div class="post-metadata">

**Author:** ![imukhin](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@imukhin](https://forums.foundationdb.org/u/imukhin)\
**Post date:** [September 25, 2020, 4:16pm UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/3 "2020-09-25T16:16:41Z")

</div>

@ajbeamon, thank you for the reply, I missed this message.  
The whole output of the program is:

```
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec testAPI
server listening at: [::]:2345
Internal Error @ c:\dev\cygwin\home\fdb\jenkins\node\workspace\fdbbuildjobs\fdbbuildwindows\work\_build_\src\fdbclient\multiversiontransaction.actor.cpp 1363:

panic: FoundationDB error code 4100 (An internal error occurred)

goroutine 1 [running]:
github.com/apple/foundationdb/bindings/go/src/fdb.MustOpenDefault(0x0)
        C:/Projects/go/src/github.com/apple/foundationdb/bindings/go/src/fdb/fdb.go:258 +0xe8
main.main()
        C:/Projects/go/src/gitlab.spb.openwaygroup.com/platform/go/configservice.git/cmd/test4/main.go:9 +0x36`

```

The program I executed (I extracted only lines required for test case) is:  
package main

```
import (
	"github.com/apple/foundationdb/bindings/go/src/fdb"
)

func main() {
	fdb.MustAPIVersion(600)
	fdb.MustOpenDefault()
}

```

The problematic line in fdb source (multiversiontransaction.actor.cpp 1363) is the first ASSERT in the following function:

```
// ClientInfo
void ClientInfo::loadProtocolVersion() {
	std::string version = api->getClientVersion();
	if(version == "unknown") {
		protocolVersion = ProtocolVersion(0);
		return;
	}

	char *next;
	std::string protocolVersionStr = ClientVersionRef(version).protocolVersion.toString();
	protocolVersion = ProtocolVersion(strtoull(protocolVersionStr.c_str(), &next, 16));

	ASSERT(protocolVersion.version() != 0 && protocolVersion.version() != ULLONG_MAX);
	ASSERT(next == &protocolVersionStr[protocolVersionStr.length()]);
}

```

I still have no idea why debugger breaks some assert about protocolVersion.

---

<div class="post-metadata">

**Author:** ![ajbeamon](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ajbeamon/32/13_2.png) [@ajbeamon](https://forums.foundationdb.org/u/ajbeamon)\
**Post date:** [September 25, 2020, 4:30pm UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/4 "2020-09-25T16:30:29Z")

</div>

Interesting. Are you loading any external client versions? Doing so would require setting the `EXTERNAL_CLIENT_DIRECTORY` or `EXTERNAL_CLIENT_LIBRARY` network options.

Assuming not, we could potentially try to read the string being returned by your library from the `getClientVersion` call. We can call this directly using a function in the C API: `fdb_get_client_version`, which will return a `const char*` with the string we want. If you were willing to modify your Go bindings, you could probably add a line something like this:

`fmt.Printf("%s\n", C.GoString(C.fdb_get_client_version()))`

to the end of the ApiVersion call in `fdb.go`.

---

<div class="post-metadata">

**Author:** ![imukhin](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@imukhin](https://forums.foundationdb.org/u/imukhin)\
**Post date:** [September 27, 2020, 8:26am UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/5 "2020-09-27T08:26:56Z")

</div>

@ajbeamon, I do not use multiversion client and there is only one fdb installation on my computer.  
The string returned by C.fdb\_get\_client\_version() is the same when I launch the application with or without debugger (delve):  
`6.2.25,Current version id not currently supported within Windows.,fdb00b062010001`

---

<div class="post-metadata">

**Author:** ![ajbeamon](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ajbeamon/32/13_2.png) [@ajbeamon](https://forums.foundationdb.org/u/ajbeamon)\
**Post date:** [October 5, 2020, 8:38pm UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/6 "2020-10-05T20:38:31Z")

</div>

I don’t immediately spot anything wrong with that string. I wonder if this is related to [https://github.com/apple/foundationdb/issues/3424](https://github.com/apple/foundationdb/issues/3424), which identified an issue that affects `ClientVersionRef`. This has been fixed on master but not on any prior release, so there’s probably not a great way to confirm this outside of building a patch.

---

<div class="post-metadata">

**Author:** ![ajbeamon](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ajbeamon/32/13_2.png) [@ajbeamon](https://forums.foundationdb.org/u/ajbeamon)\
**Post date:** [October 6, 2020, 10:38pm UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/7 "2020-10-06T22:38:37Z")

</div>

I’ve backported the PR addressing the issue I mentioned, which you can see here: [https://github.com/apple/foundationdb/pull/3849](https://github.com/apple/foundationdb/pull/3849). It should go into our next release, and hopefully it will resolve your issue.

---

<div class="post-metadata">

**Author:** ![imukhin](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@imukhin](https://forums.foundationdb.org/u/imukhin)\
**Post date:** [October 7, 2020, 8:31am UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/8 "2020-10-07T08:31:40Z")

</div>

@ajbeamon, thank you!

---

<div class="post-metadata">

**Author:** ![ajbeamon](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ajbeamon/32/13_2.png) [@ajbeamon](https://forums.foundationdb.org/u/ajbeamon)\
**Post date:** [October 15, 2020, 3:58pm UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/9 "2020-10-15T15:58:06Z")

</div>

You should now be able to download 6.2.27, which has the patch I described above. If you try it out and still run into problems, let me know.

---

<div class="post-metadata">

**Author:** ![imukhin](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@imukhin](https://forums.foundationdb.org/u/imukhin)\
**Post date:** [October 16, 2020, 6:16am UTC](https://forums.foundationdb.org/t/foundationdb-error-code-4100-when-trying-to-debug-golang-program-under-windows/2361/10 "2020-10-16T06:16:07Z")

</div>

@ajbeamon, thank you!  
With 6.2.27 debugger just works.
