Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
runtime: error error 3221226356 (C0000374) in CGO module in Windows #39127
The CGO module gorfc provides GO bindings to pre-compiled SAP NWRFC SDK binaries. The module works fine on Linux and macOS and never worked quite stable on Windows. Currently, it occasionally terminates on Windows, with heap corruption error 3221226356 (hex C0000374).
I am not sure if the toolchain and compiler flags are maybe part of the problem, here further details.
Version: 8.1.0 Architecture: x86_64 Threads: win32 Exception: seh Build revision: 0
Is this the optimal toolchain for building CGO modules on Windows, or another approach could be considered?
Compiler flags recommended for SAP NWRFC SDK bindings on Windows platform, are given for Windows native compiler and linker:
cl.exe -DSAPonNT -D_CRT_NON_CONFORMING_SWPRINTFS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_AFXDLL -DWIN32 -D_WIN32_WINNT=0x0502 -DWIN64 -D_AMD64_ -DNDEBUG -DSAPwithUNICODE -DUNICODE -D_UNICODE -DSAPwithTHREADS -Inwrfcsdk/include -EHs -Gy -J -MD -nologo -W3 -Z7 -D_ATL_ALLOW_CHAR_UNSIGNED -GL -O2 -Oy- /we4552 /we4700 /we4789 -c -FosflightClient.obj sflightClient.c link.exe -OUT:sflightClient.exe -PDB:sflightClient.pdb -NXCOMPAT -STACK:0x2000000 -SWAPRUN:NET -DEBUG -OPT:REF -DEBUGTYPE:CV,FIXUP -MACHINE:amd64 -nologo -LTCG ole32.lib oleaut32.lib uuid.lib kernel32.lib advapi32.lib user32.lib gdi32.lib winspool.lib ws2_32.lib comdlg32.lib shell32.lib sflightClient.obj nwrfcsdk/lib/sapnwrfc.lib nwrfcsdk/lib/libsapucum.lib
GCC counterparts are currently missing for some of them, commented in gorfc source)
Any help/ideas on toolchain, flags, possible root causes and troubleshooting approach, would be of a great help.
Here the details about GO environment on Windows.
PS C:\src\GO\src\github.com\sap\gorfc>go version go version go1.14 windows/amd64 PS C:\src\GO\src\github.com\sap\gorfc> go env set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\d037732\AppData\Local\go-build set GOENV=C:\Users\d037732\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=c:\src\GO set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Tools\GOLANG set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=C:\Tools\GOLANG\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=C:\src\GO\src\github.com\sap\gorfc\go.mod set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\d037732\AppData\Local\Temp\go-build050373882=/tmp/go-build -gno-record-gcc-switches
I also don't know, sorry.
But from the problem description I think it's fairly unlikely to be a toolchain or compiler flag problem. Those kind of problems manifest as build failures or immediate crashes. You are describing an occasional crash likely due to memory corruption. That is more likely to be due to some sort of error passing memory between Go and C. The fact that it works reliably on GNU/Linux and macOS does not preclude a problem on Windows, as Windows is of course quite different in many ways.
Sorry I can't help.
The example itself is simple: https://github.com/SAP/gorfc/blob/master/example/hello_gorfc.go
The challenge could be the setup, requiring SAP ABAP backend system and SAP NWRFC SDK binary libraries, installed on GO client system.
You probably don't have access to any of them and we need to find out how to test?