Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewTextView crashes when accessing buffer, however, works normally under debug #160

Open
yermak opened this issue Feb 6, 2025 · 2 comments

Comments

@yermak
Copy link

yermak commented Feb 6, 2025

pkg/v0.3.1

pkg-config --modversion gtk4
4.16.12

Code to reproduce below, fails on buffer.Text(...), works well in debug mode, suspect something with AMD specific code, looking into output.


import (
	"github.com/diamondburned/gotk4/pkg/gio/v2"
	"github.com/diamondburned/gotk4/pkg/gtk/v4"
	"log"
	"os"
)


func main() {
	app := gtk.NewApplication("com.example.minimal-textview-bug", gio.ApplicationFlagsNone)

	app.ConnectActivate(func() {
		activate(app)
	})

	if code := app.Run(os.Args); code > 0 {
		os.Exit(code)
	}
}

func activate(app *gtk.Application) {
	window := gtk.NewApplicationWindow(app)
	window.SetTitle("Minimal TextView Bug Example")
	window.SetDefaultSize(400, 300)

	vbox := gtk.NewBox(gtk.OrientationVertical, 5)
	window.SetChild(vbox)

	textView := gtk.NewTextView()
	textView.SetVExpand(true)
	scrolledWindow := gtk.NewScrolledWindow()
	scrolledWindow.SetChild(textView)
	scrolledWindow.SetPolicy(gtk.PolicyAutomatic, gtk.PolicyAutomatic)
	vbox.Append(scrolledWindow)

	getTextButton := gtk.NewButtonWithLabel("Get Text")
	vbox.Append(getTextButton)

	getTextButton.ConnectClicked(func() {
		log.Println("Button Clicked")
		buffer := textView.Buffer()

		startIter := buffer.StartIter()
		endIter := buffer.EndIter()
		text := buffer.Text(startIter, endIter, true)
		log.Printf("Text Content: %s\n", text)
	})

	window.SetVisible(true)
}

Part of the log

Exception 0xc0000005 0x0 0xb13217229 0x7ffaa04bcfc1
PC=0x7ffaa04bcfc1
signal arrived during external code execution

runtime.cgocall(0x7ff7132656e0, 0xc000029a10)
	C:/Users/Yermak/Programs/go/go1.23.5/src/runtime/cgocall.go:167 +0x3e fp=0xc0000299e8 sp=0xc000029980 pc=0x7ff712f9847e
github.com/diamondburned/gotk4/pkg/gtk/v4._Cfunc_free(0x16a7fb57b70)
	_cgo_gotypes.go:10772 +0x49 fp=0xc000029a10 sp=0xc0000299e8 pc=0x7ff7131614e9
github.com/diamondburned/gotk4/pkg/gtk/v4.(*TextBuffer).Text.(*TextBuffer).Text.func2.func3()
	C:/Users/Yermak/Programs/go/go-pkg/pkg/mod/github.com/diamondburned/gotk4/pkg@v0.3.1/gtk/v4/gtk.go:109630 +0x35 fp=0xc000029a48 sp=0xc000029a10 pc=0x7ff7131a9fd5
github.com/diamondburned/gotk4/pkg/gtk/v4.(*TextBuffer).Text(0xc00008e018, 0xc00008e020, 0xc00008e030, 0x20?)
	C:/Users/Yermak/Programs/go/go-pkg/pkg/mod/github.com/diamondburned/gotk4/pkg@v0.3.1/gtk/v4/gtk.go:109632 +0xd2 fp=0xc000029ab8 sp=0xc000029a48 pc=0x7ff7131a9f32
main.activate.func1()
	C:/Users/Yermak/Projects/GoFamilyBudget/main.go:46 +0xcd fp=0xc000029b70 sp=0xc000029ab8 pc=0x7ff71322a72d
github.com/diamondburned/gotk4/pkg/gtk/v4._gotk4_gtk4_Button_ConnectClicked(0x7ff712f360a5?, 0x7ff700000000?)
	C:/Users/Yermak/Programs/go/go-pkg/pkg/mod/github.com/diamondburned/gotk4/pkg@v0.3.1/gtk/v4/gtk_export.go:2155 +0x63 fp=0xc000029bb8 sp=0xc000029b70 pc=0x7ff7131c1163
_cgoexp_b814ad42d770__gotk4_gtk4_Button_ConnectClicked(0x7ff712f75cbe?)
	_cgo_gotypes.go:65713 +0x1d fp=0xc000029bd8 sp=0xc000029bb8 pc=0x7ff7131f8f1d
runtime.cgocallbackg1(0x7ff7131f8f00, 0x39501fe810, 0x0)
	C:/Users/Yermak/Programs/go/go1.23.5/src/runtime/cgocall.go:437 +0x295 fp=0xc000029c98 sp=0xc000029bd8 pc=0x7ff712f35fd5
runtime.cgocallbackg(0x7ff7131f8f00, 0x39501fe810, 0x0)
	C:/Users/Yermak/Programs/go/go1.23.5/src/runtime/cgocall.go:350 +0x169 fp=0xc000029d30 sp=0xc000029c98 pc=0x7ff712f35c29
runtime.cgocallbackg(0x7ff7131f8f00, 0x39501fe810, 0x0)
	<autogenerated>:1 +0x2e fp=0xc000029d58 sp=0xc000029d30 pc=0x7ff712fa9e8e
runtime.cgocallback(0xc000029de8, 0x7ff712f984b2, 0x7ff71323cf00)
	C:/Users/Yermak/Programs/go/go1.23.5/src/runtime/asm_amd64.s:1084 +0xec fp=0xc000029d80 sp=0xc000029d58 pc=0x7ff712fa530c
runtime.systemstack_switch()
	C:/Users/Yermak/Programs/go/go1.23.5/src/runtime/asm_amd64.s:479 +0x8 fp=0xc000029d90 sp=0xc000029d80 pc=0x7ff712fa3548
runtime.cgocall(0x7ff71323cf00, 0xc000029e20)
	C:/Users/Yermak/Programs/go/go1.23.5/src/runtime/cgocall.go:185 +0x72 fp=0xc000029df8 sp=0xc000029d90 pc=0x7ff712f984b2
github.com/diamondburned/gotk4/pkg/gio/v2._Cfunc_g_application_run(0x16a74ed2050, 0x1, 0x16a76892000)
	_cgo_gotypes.go:14105 +0x55 fp=0xc000029e20 sp=0xc000029df8 pc=0x7ff713066775
github.com/diamondburned/gotk4/pkg/gio/v2.(*Application).Run.func3(0x16a74ed2050, 0x1, 0x16a76892000)
	C:/Users/Yermak/Programs/go/go-pkg/pkg/mod/github.com/diamondburned/gotk4/pkg@v0.3.1/gio/v2/gio.go:42200 +0x67 fp=0xc000029e50 sp=0xc000029e20 pc=0x7ff7130847e7
github.com/diamondburned/gotk4/pkg/gio/v2.(*Application).Run(0xc0001798c0, {0xc000024090, 0x1, 0x1})
	C:/Users/Yermak/Programs/go/go-pkg/pkg/mod/github.com/diamondburned/gotk4/pkg@v0.3.1/gio/v2/gio.go:42200 +0x1f1 fp=0xc000029ef8 sp=0xc000029e50 pc=0x7ff7130846d1
main.main()
	C:/Users/Yermak/Projects/XXX/main.go:17 +0xad fp=0xc000029f50 sp=0xc000029ef8 pc=0x7ff71322a44d
runtime.main()
	C:/Users/Yermak/Programs/go/go1.23.5/src/runtime/proc.go:272 +0x27d fp=0xc000029fe0 sp=0xc000029f50 pc=0x7ff712f6c9fd
runtime.goexit({})
	C:/Users/Yermak/Programs/go/go1.23.5/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000029fe8 sp=0xc000029fe0 pc=0x7ff712fa5581```


Other details:
Windows 11 Pro, 23H2

cpuinfo.exe
Python Version: 3.12.4.final.0 (64 bit)
Cpuinfo Version: 9.0.0
Vendor ID Raw: AuthenticAMD
Hardware Raw:
Brand Raw: AMD Ryzen 7 5800X 8-Core Processor
Hz Advertised Friendly: 3.7930 GHz
Hz Actual Friendly: 3.8010 GHz
Hz Advertised: (3793000000, 0)
Hz Actual: (3801000000, 0)
Arch: X86_64
Bits: 64
Count: 16
Arch String Raw: AMD64
L1 Data Cache Size:
L1 Instruction Cache Size:
L2 Cache Size: 4194304
L2 Cache Line Size: 512
L2 Cache Associativity: 6
L3 Cache Size: 33554432
Stepping: 2
Model: 33
Family: 25
Processor Type:
Flags: 3dnow, 3dnowprefetch, abm, adx, aes, apic, avx, avx2, bmi1, bmi2, clflush, clflushopt, clwb, cmov, cmp_legacy, cr8_legacy, cx16, cx8, de, dts, erms, f16c, fma, fpu, fxsr, ht, hypervisor, ia64,
invpcid, lahf_lm, lm, mca, mce, misalignsse, mmx, monitor, movbe, msr, mtrr, osvw, osxsave, pae, pat, pclmulqdq, perfctr_core, pge, pni, popcnt, pqe, pqm, pse, pse36, rdpid, rdrnd, rdseed, sep, sepamd
, serial, sha, smap, smep, ss, sse, sse2, sse4_1, sse4_2, sse4a, ssse3, tm, topoext, tsc, umip, vaes, vme, vpclmulqdq, wdt, xsave
@diamondburned
Copy link
Owner

What exactly is "debug mode"?

@diamondburned
Copy link
Owner

diamondburned commented Feb 8, 2025

I'm unable to reproduce this on my end:

2025/02/07 18:12:55 Button Clicked
2025/02/07 18:12:55 Text Content: 
2025/02/07 18:12:56 Button Clicked
2025/02/07 18:12:56 Text Content: 
2025/02/07 18:12:56 Button Clicked
2025/02/07 18:12:56 Text Content: 
2025/02/07 18:12:56 Button Clicked
2025/02/07 18:12:56 Text Content: 
2025/02/07 18:12:56 Button Clicked
2025/02/07 18:12:56 Text Content: 

Information:

OS: NixOS 25.05.20250204.799ba5b (Warbler) x86_64 
Kernel: 6.13.1 
CPU: AMD Ryzen 5 7600X (12) @ 5.453GHz
go version go1.22.4 linux/amd64
gotk4 commit 5fcf61c75060a37dc3d48c64e3eb90d5eea983c4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants