rkd77 / elinks

Fork of elinks
Other
350 stars 37 forks source link

Search terms should not be forgotten when navigating #76

Open slackhead opened 4 years ago

slackhead commented 4 years ago

Felinks git pull 2020-10-28

It would be nice if felinks would keep the current search term indefinitely, until you type a different term or clear it.

After doing a search on a page, and then following a link elsewhere and clicking 'n' for next, the search term seems to have been lost. The behaviour after navigating and clicking 'n'ext seems to be a bit random at the moment, and hard to say exactly what's happening.

rkd77 commented 4 years ago

If I get it, you want to search once and see search results on every page. I added boolean option "document.browse.search.reset", default 1. If you set it to 0, you'll get "search once".

slackhead commented 4 years ago

I can see the search terms highlighted, but pressing 'n' doesn't seem to work.

slackhead commented 4 years ago

After a quick test with this commit.

What works: Navigating back and forward, or using history, and using search next/previous keys.

What doesnt work yet: Search next in new tab or new window causes a segfault.

Apart from segfault, this is how the original elinks worked.

rkd77 commented 4 years ago

@slackhead, could you describe step by step how to reproduce segfaults, because it is not obvious for me. Do you have js compiled-in or not?

slackhead commented 4 years ago

I don't have js compiled in at the moment because my js package is the wrong version. Also the old js185 that elinks used kept seqfaulting and made elinks crash a lot, so I got used to not using it.

This is how I made it segfault:

1 Do a search in a page. 2 Open a link from that page in a new window or tab 3 Press 'n'

It crashes after a second or 2.

elinks(dump_backtrace+0x25)[0x483865] elinks[0x46176e] elinks[0x461c53] /lib64/libpthread.so.0(+0x113b0)[0x7f20850e73b0] elinks[0x491f10] elinks(do_action+0x62e)[0x487e2e] elinks(send_event+0x7b)[0x4973ab] elinks(in_term+0x669)[0x47bd59] elinks(select_loop+0x48f)[0x4590df] elinks(main+0x38)[0x415f88] /lib64/libc.so.6(__libc_start_main+0xf0)[0x7f20841cb7d0] elinks(_start+0x29)[0x416089]

A specific example that I can repeat:

1 Search duckduckgo for 'linux "reset" framebuffer' 2 Open search box and search for 'reset' 3 Open the first link in the results in a new window 4 Press 'n'

The same happens if opening in a new (only test foreground) tab. This is what I build felinks with (my build script converts to configure options):

FASTMEM=yes HTMLHL=no LZMA=yes TRE=yes BROTLI=yes LIBDOM=no DEBUG=no

MOUSE=no GPM=no EXMODE=no

GUILE=no PERL=yes PYTHON=no LUA=no ECMA=no

FSP=no FTP=yes FINGER=no GOPHER=yes

Looking at that I wonder if fastmem is a problem

*edit: still crashes without fastmem

rkd77 commented 4 years ago

I cannot reproduce it. If this latest commit did not help, could you compile without backtrace, "catch" coredump, and show: gdb ./elinks core.*

bt

slackhead commented 4 years ago

Sorry for the delay. This is after doing the search as above, opening a new tab on first link and pressing ' n'.

Edit* try again

Core was generated byelinks'. Program terminated with signal SIGABRT, Aborted.

0 0x00007f686c8983f8 in raise () from /lib64/libc.so.6

(gdb) bt full

0 0x00007f686c8983f8 in raise () from /lib64/libc.so.6

No symbol table info available.

1 0x00007f686c899ffa in abort () from /lib64/libc.so.6

No symbol table info available.

2 0x000000000046ce33 in sig_segv (term=) at signals.c:154

No locals.

3 0x000000000046d3a3 in got_signal (sig=) at signals.c:266

    s = <optimized out>
    saved_errno = 0

4

No symbol table info available.

5 0x00000000004a4bae in move_search_number (number=0, doc_view=0x17719c0, ses=0x17a3e00) at search.c:1374

    pt = 0x0
    y = <optimized out>
    step = <optimized out>
    ret = FIND_ERROR_HIT_BOTTOM
    x = <optimized out>

6 move_search_do (ses=ses@entry=0x17a3e00, doc_view=doc_view@entry=0x17719c0, direction=direction@entry=1)

at search.c:1335
    number = <optimized out>

7 0x00000000004a5dca in move_search_next (ses=ses@entry=0x17a3e00, doc_view=doc_view@entry=0x17719c0)

at search.c:1343

No locals.

8 0x000000000049842f in do_action (ses=ses@entry=0x17a3e00, action_id=action_id@entry=ACT_MAIN_FIND_NEXT,

verbose=verbose@entry=0) at action.c:191
    status = FRAME_EVENT_OK
    term = 0x1771d30
    doc_view = 0x17719c0
    link = <optimized out>

---Type to continue, or q to quit---

9 0x00000000004ac6dc in send_kbd_event (ev=0x7ffd16063220, doc_view=0x17719c0, ses=0x17a3e00) at view.c:1685

    event = 369504800
    action_id = ACT_MAIN_FIND_NEXT

10 send_event (ses=0x17a3e00, ev=0x7ffd16063220) at view.c:1741

    doc_view = 0x17719c0

11 0x0000000000488e39 in handle_interlink_event (ilev=0x1771ef8, term=0x1771d30) at event.c:395

    utf8_io = <optimized out>
    key = 110
    modifier = KBD_MOD_NONE
    info = 0x0
    interlink = 0x1771ee0
    tev = {ev = EVENT_KBD, info = {mouse = {x = 110, y = 0, button = 0}, keyboard = {key = 110,
          modifier = KBD_MOD_NONE}, size = {width = 110, height = 0}}}

12 in_term (term=0x1771d30) at event.c:502

    ev = 0x1771ef8
    interlink = 0x1771ee0
    r = <optimized out>
    iq = 0x1771ef8 "\001"

13 0x00000000004629ef in select_loop (init=init@entry=0x461630 ) at select.c:589

    k = 0
    timeout = <optimized out>
    i = 3
    n = 1
    has_timer = <optimized out>
    t = {sec = 0, usec = 391614}
    last_time = {sec = 1604493414, usec = 878123}
    select_errors = 0

14 0x0000000000415758 in main (argc=, argv=) at main.c:357

No locals. `

slackhead commented 4 years ago

I've just spotted a bug in my build script that is the cause of --enable-debug not building :-)

slackhead commented 4 years ago

CFLAGS=-m64 -O2 -fPIC -L/usr/lib64 -ggdb CXXFLAGS=-m64 -O2 -fPIC -L/usr/lib64 -ggdb

./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --docdir=/usr/doc/felinks-git20201104 --with-bzlib --with-zlib --disable-nls --build=x86_64-slackware-linux

rkd77 commented 4 years ago

Hmm, as root echo core > /proc/sys/kernel/core_pattern Then as plain user, ./configure \ ... \ --disable-backtrace

Run elinks, and in case of segfault core will be generated. Here is sample a bit artificilal:

gdb src/elinks core.17006

Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by `src/elinks'. Program terminated with signal SIGSEGV, Segmentation fault.

0 0x000000000049df92 in move_search_do (ses=ses@entry=0x1d5abe0, doc_view=doc_view@entry=0x0, direction=direction@entry=1)

at search.c:1316

1316 if (!doc_view->document->number_of_search_points) { (gdb) bt

0 0x000000000049df92 in move_search_do (ses=ses@entry=0x1d5abe0, doc_view=doc_view@entry=0x0, direction=direction@entry=1)

at search.c:1316

1 0x000000000049f53a in move_search_next (ses=ses@entry=0x1d5abe0, doc_view=doc_view@entry=0x0) at search.c:1343

2 0x0000000000493bb7 in do_action (ses=ses@entry=0x1d5abe0, action_id=action_id@entry=ACT_MAIN_FIND_NEXT, verbose=verbose@entry=0)

at action.c:191

3 0x00000000004a3b61 in send_kbd_event (ev=0x7fff44bf1ca0, doc_view=0x1d5ae30, ses=0x1d5abe0) at view.c:1685

4 send_event (ses=0x1d5abe0, ev=0x7fff44bf1ca0) at view.c:1741

5 0x00000000004876e9 in term_send_event (ev=, term=) at event.c:134

6 term_send_ucs (modifier=, u=, term=) at event.c:146

7 handle_interlink_event (ilev=0x1d5e7b8, term=0x1d5e4c0) at event.c:438

8 in_term (term=0x1d5e4c0) at event.c:502

9 0x0000000000462bc7 in select_loop (init=init@entry=0x461940 ) at select.c:589

10 0x00000000004171c0 in main (argc=, argv=) at main.c:357

Such backtrace with line numbers and parameters, would help a little.

slackhead commented 4 years ago

Program terminated with signal SIGSEGV, Segmentation fault.

0 0x00000000004af19e in move_search_number (number=0, doc_view=0x26e41f0, ses=0x26e4040)

at search.c:1374

1374 x = pt[number].x; [Current thread is 1 (Thread 0x7fc9b77dd700 (LWP 29134))] (gdb) bt

0 0x00000000004af19e in move_search_number (number=0, doc_view=0x26e41f0, ses=0x26e4040)

at search.c:1374

1 move_search_do (ses=ses@entry=0x26e4040, doc_view=doc_view@entry=0x26e41f0,

direction=direction@entry=1) at search.c:1335

2 0x00000000004b03ba in move_search_next (ses=ses@entry=0x26e4040,

doc_view=doc_view@entry=0x26e41f0) at search.c:1343

3 0x00000000004a26df in do_action (ses=ses@entry=0x26e4040,

action_id=action_id@entry=ACT_MAIN_FIND_NEXT, verbose=verbose@entry=0) at action.c:191

4 0x00000000004b6ffc in send_kbd_event (ev=0x7ffe40605b00, doc_view=0x26e41f0,

ses=0x26e4040) at view.c:1685

5 send_event (ses=0x26e4040, ev=0x7ffe40605b00) at view.c:1741

6 0x0000000000492f29 in handle_interlink_event (ilev=0x269a5d8, term=0x269a410)

at event.c:395

7 in_term (term=0x269a410) at event.c:502

8 0x000000000046bdef in select_loop (init=init@entry=0x46aa00 ) at select.c:589

9 0x0000000000416228 in main (argc=, argv=) at main.c:357

rkd77 commented 4 years ago

@slackhead try now.

slackhead commented 4 years ago

It's good. Thanks.