Hello everyone,

I wanted to know whether the issue of Application Verifier ( 
https://docs.microsoft.com/en-us/windows/desktop/win7appqual/application-verifier
 
) crashing when used on a C (or C++) program linked with a CGO-generated 
DLL.
This happens with Golang 1.11.4 and 1.11.5 for sure.

The repro is the following (needs a Windows with MingW-w64 installed and in 
the PATH):

1) Have this file in a folder with the name "main.go":
package main

import "C"
import "fmt"

//export test
func test(str *C.char) int64 {
    fmt.Print(C.GoString(str))
    return 42
}

func main() {
}


2) Execute "go build -buildmode=c-shared -o test.dll"

3) Create the following file in the same older folder with the name 
"main.c":
#include <stdio.h>

#include "test.h"

int main() {
    printf("%lld", test("Foo\n"));
    return 0;
}

4) Run "gcc -g test.dll main.c -o test.exe"
5) In Application Verifier, enable the "Basics" category for the test.exe 
executable
6) Start "gdb test.exe" and run the program
7) Boom

I suspect the "_rt0_amd64_windows_lib" routine (written in Go ASM, in 
src/runtime/rt0_windows_amd64.s in Golang's sources) to do some nasty stuff 
from a Windows ABI point-of-view (it looks correct from what I could 
understand when reading it though).
Then Application Verifier tries to walk the stack from some low-level heap 
allocation function, and crashes doing so.

Hoping someone here might have som insight for me,
Thanks,

Pierre FRANCO

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to