bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

segmentation fault from form_driver


From: Sam L'Ecuyer
Subject: segmentation fault from form_driver
Date: Wed, 19 Oct 2011 17:02:35 -0500

Hi,

-- As a full warning, it's entirely possible that this is not a curses
bug (please tell me if it's not) --

I don't know if this is completely the wrong place to be asking this,
but as I'm writing language bindings, I thought I'd get input from the
ncurses side of things

I'm writing ncurses bindings for the go programming language (Ken
Thompson and Rob Pike's latest project).
I don't *think* it's a bug with my bindings, but I could be wrong.
They are available at https://github.com/samlecuyer/gocurse

I have a loop that does the following:

func (w *Widget) loop() {
        for {
                switch inp := w.formWin.Getch(); inp {
                case KEY_DOWN, 9:
                        w.form.Drive(REQ_NEXT_FIELD)
                        w.form.Drive(REQ_END_LINE)
                ... whole lotta different requests ...
                case KEY_ENTER, 10, 13:
                        w.form.Drive(REQ_LAST_FIELD)
                        w.validateAndYield()
                default:
                        w.form.Drive(inp)
        }
        UpdatePanels()
        DoUpdate()
        }
}

The problem that I'm getting is that I perform some serious
calculations (http requests and such) in validatedAndYield(), none of
which touch the UI.  The next time I press a key that results in a
non-data call to form_driver, my application crashes.

-------------------------------------------------------------------------------------------------------------
go stacktrace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x40 pc=0x22a2895]

goroutine 1 [syscall]:
curses/forms._Cfunc_form_driver(0x23030b0, 0x207)
/Users/slecuyer/github/gocurse/forms/_obj/_cgo_defun.c:250 +0x2f

/Users/slecuyer/github/gocurse/forms/_obj/forms.cgo1.go:-42 +0x2d
-----------------------------------------------------------------------------------------------------------
>From gdb:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000040
[Switching to process 56107 thread 0x1903]
0x00000000022a2895 in _nc_Set_Current_Field ()

(gdb) bt
#0  0x00000000022a2895 in _nc_Set_Current_Field ()
#1  0x00000000022a3298 in _nc_Internal_Validation ()
#2  0x00000000022a4a61 in form_driver ()
#3  0x000000000002c3e6 in ?? ()
----------------------------------------------------------------------------------------------------------

Is there something I need to do, or can do to make sure my form didn't
somehow get into a bad state while I was doing processing on another
thread?

--
Thanks,
Sam L'Ecuyer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]