jarun / ddgr

:duck: DuckDuckGo from the terminal
GNU General Public License v3.0
2.93k stars 139 forks source link

seq fault on Cntrl-q #20

Closed bkerin closed 6 years ago

bkerin commented 6 years ago

when I do ddgr hello world, then type Cntrl-q at the prompt, ddgr dies with a seg fault

It would be sort of nice if Cntrl-q also meant quit. I have a bit of a crazed personal mission of making Cntrl-q mean "get rid of the current thing" across all my software. Of course it sort of works as it is so maybe I shouldn't be reporting this issue :)

jarun commented 6 years ago

I know Linux GUI apps quit on ^Q but ^Q has an entirely different meaning in the CLI world:

$ stty -a
...
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O;
min = 1; time = 0;
...

We have three ways to quit from the utility. Should be enough.

Also can you please share the exact steps? I am pressing ^Q at the prompt but I don't see the segfault.

bkerin commented 6 years ago

On 11/5/17, Arun Prakash Jana notifications@github.com wrote:

I know Linux GUI apps quit on ^Q but ^Q has an entirely different meaning in the CLI world:


$ stty -a
...
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 =
<undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O;
min = 1; time = 0;

Yes but start and stop are pretty useless nowadays because almost no terminal output is slow enough for them to be viable, it's best to disable them. Then command line apps can work like (most) GUI ones with a little .inputrc customization

We have three ways to quit from the utility. Should be enough.

Also can you please share the exact steps? I am pressing ^Q at the prompt but I don't see the segfault.

I just start the app with the command line shown in the first example, then put Cntrl-Q at the first prompt. It's possible that it does this for me because I have Cntrl-Q disabled:

$ stty -a speed 38400 baud; rows 74; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ; stop = ; susp = ^Z; ..

Britton

jarun commented 6 years ago

Can you please share the output from from the Exception?

bkerin commented 6 years ago

It's real, so this close is premature. It's almost certainly due to this stuff from my ~/.inputrc:

I don't know what magic word to use for sqlite3 so we just correct for the

other cases.

set keymap vi-insert Control-q: ".exit\nq(save=\"no\")\n" set keymap vi-move Control-q: ".exit\nq(save=\"no\")\n"

I also don't know what magic word to use for R (the one that seems to be set

in the source doesn't work). This is what i used to use for R, plus a bit

that was supposed to make sqlite3 work as well. But unfortunately trying to

do both makes R seg fault on exit in an annoying way, and I don't use R at

the moment anyway.

Control-q: "q(save=\"no\")\n;\n.exit\n"

The GNU readline docs use a capital B, so we do that too, by godfrey.

$if Bash set keymap vi-insert Control-q: "\C-d" set keymap vi-move Control-q: "\C-d" $endif

$if ngspice set keymap vi-insert Control-q: "quit\n" set keymap vi-move Control-q: "quit\n" $endif

[More similar program-specific stanzas snipped]

omnicomplete (which maybe is a python module?) shouldn't crash with a seg fault because that first ".exit\nq(save=\"no\")\n" ends up getting sent to it, but it does.

The annoying thing about ~/.inputrc is those program names (Bash, ngspice, etc.) are barely documented so you have to guess or look at source to figure out what they are, and in some cases (e.g. sqlite3) I never managed to figure it out. So this would be a useful thing for omnicomplete to carefully document, if it doesn't already. It's appropriate to document at this level of detail, because command line programs like omnicomplete and ddgr are aiming at users who stand a good chance of caring about this sort of customizability.

On 11/9/17, Arun Prakash Jana notifications@github.com wrote:

Closed #20.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jarun/ddgr/issues/20#event-1333908253

jarun commented 6 years ago

I copied the content above into ~/.inputrc and tried ^Q. No exception.

users who stand a good chance of caring about this sort of customizability

No, my other utility googler has thousands of users already over several years and no one came up with this issue so far. it's very much your personal customization.

As I requested in my last comment, if you can provide the _output_in_theterminal when this Exception happens, I'll see if I can make something out of it.

bkerin commented 6 years ago

$ ddgr hello world

(1) Digital, Social, Mobile Marketing | HelloWorld [www.helloworld.com] Rich engagement platform empowers marketers to motivate and measure consumer behavior through promotions, loyalty solutions and mobile messaging.

(2) "Hello, World!" program - Wikipedia [en.wikipedia.org] A "Hello, World!" program is a computer program that outputs or displays "Hello, World!" to a user. Being a very simple program in most programming languages, it is ...

(3) Hello World - Simple source code examples [helloworld.org] Ever wondered how to write Hello World in some random programming language? Here we list examples of the Hello World program in various programming languages.

(4) Hello World - Bloomberg.com [www.bloomberg.com] Hello World invites the viewer to come on a journey. It's a journey that stretches across the globe to find the inventors, scientists and technologists shaping our ...

(5) BUMP OF CHICKEN「Hello,world!」 - YouTube [www.youtube.com] Hello,world!(TVアニメ「血界戦線」オープニング・テーマ) 02. コロニー(映画「寄 生獣 完結編」主題歌) 「H ...

(6) Total immersion, Serious fun! with Hello-World! [www.hello-world.com] Main index for hello-world: links to login and all of the languages

(7) Hello world | Etsy [www.etsy.com] Shop for hello world on Etsy, the place to express your creativity through the buying and selling of handmade and vintage goods.

(8) Hello, World! - YouTube [www.youtube.com] Introduzione ai file di testo nel linguaggio c; funzioni fopen fclose fgets feof ; avvio programma da terminale mac. Pensate bene all'output come mai si ha una doppia ...

(9) Hello World - Home & Lifestlye [shophelloworld.com] Hello World . Philadelphia . Home & Lifestyle . Modern Furniture . Decor . Jewelry . Chilewich . Gifts

(10) More than 700 FREE French games and activities - Hello-World [www.hello-world.com] Index page for all of the French games and activities.

(11) HelloWorld.rs | Svi IT poslovi, kompanije i poslodavci na ... [www.helloworld.rs] HelloWorld.rs vam pomaže da pronađete i konkurišete na IT poslove koje nude najbolji poslodavci i kompanije iz vašeg grada. otvorite nalog i pogledajte ponude!

(12) Go by Example: Hello World [gobyexample.com] Our first program will print the classic "hello world" message. Here's the full source code.

(13) Lady Antebellum - Hello World Lyrics | MetroLyrics [www.metrolyrics.com] Lyrics to 'Hello World' by Lady Antebellum. Traffic crawls, cell phone calls, talk video screams at me / Through my tinted window I see a little girl, rust red

(14) Hello, World Page! - Louisiana Tech University [www2.latech.edu] Hello World! Welcome to the ACM "Hello World" project. Everyone has seen the Hello World program used as a first exposure to a new language or environment.

(15) Hello World [helloworld.raspberrypi.org] ISSUE 3. In issue 3 of of Hello World magazine our international panel of experts discusses innovative approaches and technologies for assessing programming skills.

(16) The HTML Programming Language: Hello World [groups.engin.umd.umich.edu] The HTML Programming Language Hello World Example Program. Click below to go directly to a specific section: Description| Source Code| Sample Run

(17) Helloworld Travel - Deals on Accommodation, Flights, Cruises ... [www.helloworld.com.au] Discover the best deals on flights, hotels, cruises and holiday packages at Helloworld Travel. Book online or find your nearest Helloworld Travel agency today.

(18) Cheap Flights & Holiday Packages | helloworld [helloworld.co.nz] Cheap flights on sale now with helloworld! Contact one of our travel agents today for great deals on cheap holidays, hotels and low airfares.

(19) Arduino - HelloWorld [www.arduino.cc] "Hello World!" The LiquidCrystal library allows you to control LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and ...

(20) Hello, world! | Hello, World! [hello-world.io] When a programmer picks up a new language it is customary to write the timeless Hello World application to ease your way into a daunting codebase with an overly ...

(21) The C Programming Language: Hello world! Example Program [groups.engin.umd.umich.edu] The C Programming Language Hello world! Example Program. / Hello World program / #include main() { printf("Hello World");}

(22) Hello World! | Watch Full Episodes & More! - Discovery [www.discovery.com] Hello World! Official Site. Watch Full Episodes, Get Behind the Scenes, Meet the Cast, and much more. Stream Hello World! FREE with Your TV Subscription!

(23) Hello World (song) - Wikipedia [en.wikipedia.org] "Hello World" is a song written by Tom Douglas, Tony Lane and David Lee, and recorded by American country music group Lady Antebellum. It was released in October 2010 ...

(24) The Hello World Collection [helloworldcollection.github.io] The largest collection of Hello World programs on the Internet.

(25) Hello World - 22 Photos & 11 Reviews - Home Decor - 3610 ... [www.yelp.com] 11 reviews of Hello World "So in love with this store! I walked by last Saturday night and saw this diagram of the skull hanging on the wall and was obsessed! The ...

(26) "Hello World!" for Microsoft Windows (The Java™ Tutorials ... [docs.oracle.com] This beginner Java tutorial describes getting started with Java and setting up your Netbeans IDE

(27) HelloWorld - Home | Facebook [www.facebook.com] HelloWorld, Southfield, Michigan. 15K likes. HelloWorld is a digital marketing solutions company working with the world's leading brands across all...

(28) Hello World · GitHub Guides [guides.github.com] The Hello World project is a time-honored tradition in computer programming. It is a simple exercise that gets you started when learning something new.

(29) Contact Us | HelloWorld [www.helloworld.com] If you're a recent winner or just need help with an existing game, look for the FAQ link on the promotion's website and click Contact Us.

(30) Manning | Hello World! [www.manning.com] Your computer won't respond when you yell at it. Why not learn to talk to your computer in its own language? Whether you want to write games, start a business, or you ...

ddgr (? for help) .exit Segmentation fault (core dumped)

On 11/9/17, Arun Prakash Jana notifications@github.com wrote:

I copied the content above into ~/.inputrc and tried ^Q. No exception.

users who stand a good chance of caring about this sort of customizability

No, my other utility googler has thousands of users already over several years and no one came up with this issue.

As I requested in my last comment, if you can provide the _output_in_theterminal when this Exception happens, I'll see if I can make something out of it.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jarun/ddgr/issues/20#issuecomment-343365137

bkerin commented 6 years ago

Here is my full stty -a output:

$ stty -a speed 38400 baud; rows 74; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ; stop = ; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

My full .innputrc is included below as well. This is probably an omnicomplete bug of some sort, and not a bug in your program, but I doubt I'm the only one who uses readline and .inputrc a lot and so other people somewhere are likely hitting the bug, even if googlers/ddgr'ers aren't.

set input-meta on set output-meta on

set editing-mode vi

This next line crashes recent bashes, I reported bug about it

set isearch-terminators "\r"

set keymap vi-insert "js":vi-movement-mode "\C-p":previous-history "\C-n":next-history

set keymap vi-move SPACE:backward-char "\C-p":previous-history "\C-n":next-history "/":reverse-search-history

Mark completed direcories and symlinks to directories with trailing slashes.

set mark-directories set mark-symlinked-directories

When "completing" from the middle of a word, don't re-output any remaining

portion of the existing word that matches the completion.

set skip-completed-text

Make C-q exit the current application (if alone on a command line). FIXME:

if there is stuff on the command line it instead gets executed (except under

R) which seems a bit unfortunate.

I don't know what magic word to use for sqlite3 so we just correct for the

other cases.

set keymap vi-insert Control-q: ".exit\nq(save=\"no\")\n" set keymap vi-move Control-q: ".exit\nq(save=\"no\")\n"

I also don't know what magic word to use for R (the one that seems to be set

in the source doesn't work). This is what i used to use for R, plus a bit

that was supposed to make sqlite3 work as well. But unfortunately trying to

do both makes R seg fault on exit in an annoying way, and I don't use R at

the moment anyway.

Control-q: "q(save=\"no\")\n;\n.exit\n"

The GNU readline docs use a capital B, so we do that too, by godfrey.

$if Bash set keymap vi-insert Control-q: "\C-d" set keymap vi-move Control-q: "\C-d" $endif

$if ngspice set keymap vi-insert Control-q: "quit\n" set keymap vi-move Control-q: "quit\n" $endif

I had to dig this out of the R source code, but it still doesn't work:

$if RCustomCompletion set keymap vi-insert Control-q: "q(save=\"no\")\n" set keymap vi-move Control-q: "q(save=\"no\")\n" $endif

$if bc set keymap vi-insert Control-q: "\C-d" set keymap vi-move Control-q: "\C-d" $endif

$if gdb set keymap vi-insert Control-q: "\C-d" set keymap vi-move Control-q: "\C-d" $endif

$if mysql set keymap vi-insert Control-q: "\C-d" set keymap vi-move Control-q: "\C-d" $endif

FIXME: this doesn't seem to work, how annoying

$if Sqlite set keymap vi-insert Control-q: "\C-d" set keymap vi-move Control-q: "\C-d" $endif

$if perldb set keymap vi-insert Control-q: "\C-d" set keymap vi-move Control-q: "\C-d" $endif

This one is untested:

$if psql set keymap vi-insert Control-q: "\C-d" set keymap vi-move Control-q: "\C-d" $endif

Britton

jarun commented 6 years ago

I believe the answer lies in the core dump. Can you share the backtrace from it?

bkerin commented 6 years ago

It's bee a while since I used gdb, so I'm not sure I got the incantation to get a backtrace right. I did this:

  1. Installed python3.4-dbg (debian package)
  2. Ran ddgr using it with this command: python3.4-dbg /home/bkerin/local/bin/ddgr hello world
  3. Triggered bug as described previously
  4. Launched gdb with this command: gdb python3.4-dbg core
  5. Typed 'bt' to get the backtrace as shown below:

139 $ gdb python3.4-dbg core GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from python3.4-dbg...done.

warning: core file may not match specified executable file. [New LWP 31210] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `python3.4-dbg /home/bkerin/local/bin/ddgr hello world'. Program terminated with signal SIGSEGV, Segmentation fault.

0 0x0000000000000000 in ?? ()

(gdb) bt

0 0x0000000000000000 in ?? ()

1 0x00007fbbde1ab92e in rl_callback_read_char ()

from /lib/x86_64-linux-gnu/libreadline.so.6

2 0x00007fbbde3cd0b2 in readline_until_enter_or_signal (

prompt=0x7fbbddf2ec40 "\033[7mddgr (? for help)\033[0m ",
signal=0x7fff0e366d98)
at /scratch/packages/python/3.4/python3.4-3.4.2/Modules/readline.c:1103

3 0x00007fbbde3cd203 in call_readline (

sys_stdin=0x7fbbe0d0a4e0 <_IO_2_1_stdin_>,
sys_stdout=0x7fbbe0d0a2a0 <_IO_2_1_stdout_>,
prompt=0x7fbbddf2ec40 "\033[7mddgr (? for help)\033[0m ")
at /scratch/packages/python/3.4/python3.4-3.4.2/Modules/readline.c:1191

4 0x00000000006e9534 in PyOS_Readline (

sys_stdin=0x7fbbe0d0a4e0 <_IO_2_1_stdin_>,
sys_stdout=0x7fbbe0d0a2a0 <_IO_2_1_stdout_>,
prompt=0x7fbbddf2ec40 "\033[7mddgr (? for help)\033[0m ")
at ../Parser/myreadline.c:211

5 0x00000000005a0840 in builtin_input (

self=<module at remote 0x7fbbe0927358>,
args=('\x1b[7mddgr (? for help)\x1b[0m ',)) at ../Python/bltinmodule.c:1785

6 0x00000000004c9525 in PyCFunction_Call (

func=<built-in method input of module object at remote 0x7fbbe0927358>,
arg=('\x1b[7mddgr (? for help)\x1b[0m ',), kw=0x0)
at ../Objects/methodobject.c:93

7 0x00000000005bd5b8 in call_function (pp_stack=0x7fff0e367480, oparg=1)

at ../Python/ceval.c:4234

8 0x00000000005b59c0 in PyEval_EvalFrameEx (

f=Frame 0x1bb0288, for file /home/bkerin/local/bin/ddgr, line

1180, in read_next_command (self=<DdgCmd(_conn=<DdgConnection(_conn=None, _u='https://duckduckgo.com/html', _proxies={'https': None}, _host=None, _port=None, cookie='') at remote 0x7fbbddf339b0>, _ddg_url=<DdgUrl(_page=0, _query_dict={}, path='/html/', _safe=1, scheme='https', fragment='', _sites=None, _keywords=['hello', 'world'], _qrycnt=30, _region='us-en', params='', _curindex=1) at remote 0x7fbbddf33a18>, _opts=<Namespace(show_browser_logs=False, url_handler=None, debug=False, unsafe=False, region='us-en', keywords=[...], ducky=False, expand=False, json=False, colorstr='oCdgxy', proxy=None, noua=False, colorize=True, complete=None, sites=None, noninteractive=False) at remote 0x7fbbddf33948>, _urltable={'26': 'https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html', '29': 'https://www.helloworld.com/contact', '23': 'https://en.wikipedia.org/wiki/Hello_World_(song)', '24': 'https://helloworldcollection.github.io/', '19': 'https://w...(truncated), throwflag=0) at ../Python/ceval.c:2836

9 0x00000000005bdbac in fast_function (

func=<function at remote 0x7fbbddf2c280>, pp_stack=0x7fff0e368d00, n=1,
na=1, nk=0) at ../Python/ceval.c:4331

10 0x00000000005bd7eb in call_function (pp_stack=0x7fff0e368d00, oparg=0)

at ../Python/ceval.c:4259

11 0x00000000005b59c0 in PyEval_EvalFrameEx (

f=Frame 0x1a66968, for file /home/bkerin/local/bin/ddgr, line

1287, in cmdloop (self=<DdgCmd(_conn=<DdgConnection(_conn=None, _u='https://duckduckgo.com/html', _proxies={'https': None}, _host=None, _port=None, cookie='') at remote 0x7fbbddf339b0>, _ddg_url=<DdgUrl(_page=0, _query_dict={}, path='/html/', _safe=1, scheme='https', fragment='', _sites=None, _keywords=['hello', 'world'], _qrycnt=30, _region='us-en', params='', _curindex=1) at remote 0x7fbbddf33a18>, _opts=<Namespace(show_browser_logs=False, url_handler=None, debug=False, unsafe=False, region='us-en', keywords=[...], ducky=False, expand=False, json=False, colorstr='oCdgxy', proxy=None, noua=False, colorize=True, complete=None, sites=None, noninteractive=False) at remote 0x7fbbddf33948>, _urltable={'26': 'https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html', '29': 'https://www.helloworld.com/contact', '23': 'https://en.wikipedia.org/wiki/Hello_World_(song)', '24': 'https://helloworldcollection.github.io/', '19': 'https://www.arduino...(truncated), throwflag=0) at ../Python/ceval.c:2836

12 0x00000000005bdbac in fast_function (

func=<function at remote 0x7fbbddf2cc90>, pp_stack=0x7fff0e36a580, n=1,
na=1, nk=0) at ../Python/ceval.c:4331

13 0x00000000005bd7eb in call_function (pp_stack=0x7fff0e36a580, oparg=0)

at ../Python/ceval.c:4259

14 0x00000000005b59c0 in PyEval_EvalFrameEx (

f=Frame 0x1a55418, for file /home/bkerin/local/bin/ddgr, line 1559, in main

(opts=<Namespace(show_browser_logs=False, url_handler=None, debug=False, unsafe=False, region='us-en', keywords=['hello', 'world'], ducky=False, expand=False, json=False, colorstr='oCdgxy', proxy=None, noua=False, colorize=True, complete=None, sites=None, noninteractive=False) at remote 0x7fbbddf33948>, colors=<Colors at remote 0x7fbbde5ede18>, repl=<DdgCmd(_conn=<DdgConnection(_conn=None, _u='htt---Type to continue, or q to quit--- ps://duckduckgo.com/html', _proxies={'https': None}, _host=None, _port=None, cookie='') at remote 0x7fbbddf339b0>, _ddg_url=<DdgUrl(_page=0, _query_dict={}, path='/html/', _safe=1, scheme='https', fragment='', _sites=None, _keywords=[...], _qrycnt=30, _region='us-en', params='', _curindex=1) at remote 0x7fbbddf33a18>, _opts=<...>, _urltable={'26': 'https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html', '29': 'https://www.helloworld.com/contact', '23': 'https://en.wikipedia.org/wiki/Hello_World_(song)', '24': 'https://helloworl...(truncated), throwflag=0) at ../Python/ceval.c:2836

15 0x00000000005bdbac in fast_function (

func=<function at remote 0x7fbbddf2d560>, pp_stack=0x7fff0e36be00, n=0,
na=0, nk=0) at ../Python/ceval.c:4331

16 0x00000000005bd7eb in call_function (pp_stack=0x7fff0e36be00, oparg=0)

at ../Python/ceval.c:4259

17 0x00000000005b59c0 in PyEval_EvalFrameEx (

f=Frame 0x16d0308, for file /home/bkerin/local/bin/ddgr, line

1570, in (), throwflag=0) at ../Python/ceval.c:2836

18 0x00000000005bac18 in PyEval_EvalCodeEx (

_co=<code at remote 0x7fbbe0738580>,
globals={'COLORMAP': {'X': '\x1b[1m', 'f': '\x1b[35m', 'K':

'\x1b[92;1m', 'O': '\x1b[96;1m', 'm': '\x1b[94m', 'B': '\x1b[31;1m', 'g': '\x1b[36m', 'P': '\x1b[97;1m', 'c': '\x1b[32m', 'J': '\x1b[91;1m', 'F': '\x1b[35;1m', 'D': '\x1b[33;1m', 'A': '\x1b[30;1m', 'n': '\x1b[95m', 'k': '\x1b[92m', 'i': '\x1b[90m', 'j': '\x1b[91m', 'L': '\x1b[93;1m', 'G': '\x1b[36;1m', 'E': '\x1b[34;1m', 'C': '\x1b[32;1m', 'p': '\x1b[97m', 'd': '\x1b[33m', 'M': '\x1b[94;1m', 'H': '\x1b[37;1m', 'e': '\x1b[34m', 'y': '\x1b[7m', 'N': '\x1b[95;1m', 'Y': '\x1b[7;1m', 'a': '\x1b[30m', 'l': '\x1b[93m', 'o': '\x1b[96m', 'x': '\x1b[0m', 'b': '\x1b[31m', 'h': '\x1b[37m', 'I': '\x1b[90;1m'}, 'DDGConnectionError': <type at remote 0x1a511f8>, 'subprocess': <module at remote 0x7fbbdf73e1d8>, 'html': <module at remote 0x7fbbe04b5a58>, 'printerr': <function at remote 0x7fbbddf21a68>, 'DdgCmd': <type at remote 0x1a56968>, 'require_keywords': <function at remote 0x7fbbddf26f70>, 'completer_run': <function at remote 0x7fbbddf2d3f0>, 'sys': <module at remote 0x...(truncated), locals={'COLORMAP': {'X': '\x1b[1m', 'f': '\x1b[35m', 'K': '\x1b[92;1m', 'O': '\x1b[96;1m', 'm': '\x1b[94m', 'B': '\x1b[31;1m', 'g': '\x1b[36m', 'P': '\x1b[97;1m', 'c': '\x1b[32m', 'J': '\x1b[91;1m', 'F': '\x1b[35;1m', 'D': '\x1b[33;1m', 'A': '\x1b[30;1m', 'n': '\x1b[95m', 'k': '\x1b[92m', 'i': '\x1b[90m', 'j': '\x1b[91m', 'L': '\x1b[93;1m', 'G': '\x1b[36;1m', 'E': '\x1b[34;1m', 'C': '\x1b[32;1m', 'p': '\x1b[97m', 'd': '\x1b[33m', 'M': '\x1b[94;1m', 'H': '\x1b[37;1m', 'e': '\x1b[34m', 'y': '\x1b[7m', 'N': '\x1b[95;1m', 'Y': '\x1b[7;1m', 'a': '\x1b[30m', 'l': '\x1b[93m', 'o': '\x1b[96m', 'x': '\x1b[0m', 'b': '\x1b[31m', 'h': '\x1b[37m', 'I': '\x1b[90;1m'}, 'DDGConnectionError': <type at remote 0x1a511f8>, 'subprocess': <module at remote 0x7fbbdf73e1d8>, 'html': <module at remote 0x7fbbe04b5a58>, 'printerr': <function at remote 0x7fbbddf21a68>, 'DdgCmd': <type at remote 0x1a56968>, 'require_keywords': <function at remote 0x7fbbddf26f70>, 'completer_run': <function at remote 0x7fbbddf2d3f0>, 'sys': <module at remote 0x...(truncated), args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0) at ../Python/ceval.c:3585

19 0x00000000005a5915 in PyEval_EvalCode (co=<code at remote 0x7fbbe0738580>,

globals={'COLORMAP': {'X': '\x1b[1m', 'f': '\x1b[35m', 'K':

'\x1b[92;1m', 'O': '\x1b[96;1m', 'm': '\x1b[94m', 'B': '\x1b[31;1m', 'g': '\x1b[36m', 'P': '\x1b[97;1m', 'c': '\x1b[32m', 'J': '\x1b[91;1m', 'F': '\x1b[35;1m', 'D': '\x1b[33;1m', 'A': '\x1b[30;1m', 'n': '\x1b[95m', 'k': '\x1b[92m', 'i': '\x1b[90m', 'j': '\x1b[91m', 'L': '\x1b[93;1m', 'G': '\x1b[36;1m', 'E': '\x1b[34;1m', 'C': '\x1b[32;1m', 'p': '\x1b[97m', 'd': '\x1b[33m', 'M': '\x1b[94;1m', 'H': '\x1b[37;1m', 'e': '\x1b[34m', 'y': '\x1b[7m', 'N': '\x1b[95;1m', 'Y': '\x1b[7;1m', 'a': '\x1b[30m', 'l': '\x1b[93m', 'o': '\x1b[96m', 'x': '\x1b[0m', 'b': '\x1b[31m', 'h': '\x1b[37m', 'I': '\x1b[90;1m'}, 'DDGConnectionError': <type at remote 0x1a511f8>, 'subprocess': <module at remote 0x7fbbdf73e1d8>, 'html': <module at remote 0x7fbbe04b5a58>, 'printerr': <function at remote 0x7fbbddf21a68>, 'DdgCmd': <type at remote 0x1a56968>, 'require_keywords': <function at remote 0x7fbbddf26f70>, 'completer_run': <function at remote 0x7fbbddf2d3f0>, 'sys': <module at remote 0x...(truncated), locals={'COLORMAP': {'X': '\x1b[1m', 'f': '\x1b[35m', 'K': '\x1b[92;1m', 'O': '\x1b[96;1m', 'm': '\x1b[94m', 'B': '\x1b[31;1m', 'g': '\x1b[36m', 'P': '\x1b[97;1m', 'c': '\x1b[32m', 'J': '\x1b[91;1m', 'F': '\x1b[35;1m', 'D': '\x1b[33;1m', 'A': '\x1b[30;1m', 'n': '\x1b[95m', 'k': '\x1b[92m', 'i': '\x1b[90m', 'j': '\x1b[91m', 'L': '\x1b[93;1m', 'G': '\x1b[36;1m', 'E': '\x1b[34;1m', 'C': '\x1b[32;1m', 'p': '\x1b[97m', 'd': '\x1b[33m', 'M': '\x1b[94;1m', 'H': '\x1b[37;1m', 'e': '\x1b[34m', 'y': '\x1b[7m', 'N': '\x1b[95;1m', 'Y': '\x1b[7;1m', 'a': '\x1b[30m', 'l': '\x1b[93m', 'o': '\x1b[96m', 'x': '\x1b[0m', 'b': '\x1b[31m', 'h': '\x1b[37m', 'I': '\x1b[90;1m'}, 'DDGConnectionError': <type at remote 0x1a511f8>, 'subprocess': <module at remote 0x7fbbdf73e1d8>, 'html': <module at remote 0x7fbbe04b5a58>, 'printerr': <function at remote 0x7fbbddf21a68>, 'DdgCmd': <type at re mote 0x1a56968>, 'require_keywords': <function at remote 0x7fbbddf26f70>, 'completer_run': <function at remote 0x7fbbddf2d3f0>, 'sys': <module at remote 0x...(truncated)) at ../Python/ceval.c:773

20 0x000000000042798c in run_mod (mod=0x1773628,

filename='/home/bkerin/local/bin/ddgr',
globals={'COLORMAP': {'X': '\x1b[1m', 'f': '\x1b[35m', 'K':

'\x1b[92;1m', 'O': '\x1b[96;1m', 'm': '\x1b[94m', 'B': '\x1b[31;1m', 'g': '\x1b[36m', 'P': '\x1b[97;1m', 'c': '\x1b[32m', 'J': '\x1b[91;1m', 'F': '\x1b[35;1m', 'D': '\x1b[33;1m', 'A': '\x1b[30;1m', 'n': '\x1b[95m', 'k': '\x1b[92m', 'i': '\x1b[90m', 'j': '\x1b[91m', 'L': '\x1b[93;1m', 'G': '\x1b[36;1m', 'E': '\x1b[34;1m', 'C': '\x1b[32;1m', 'p': '\x1b[97m', 'd': '\x1b[33m', 'M': '\x1b[94;1m', 'H': '\x1b[37;1m', 'e': '\x1b[34m', 'y': '\x1b[7m', 'N': '\x1b[95;1m', 'Y': '\x1b[7;1m', 'a': '\x1b[30m', 'l': '\x1b[93m', 'o': '\x1b[96m', 'x': '\x1b[0m', 'b': '\x1b[31m', 'h': '\x1b[37m', 'I': '\x1b[90;1m'}, 'DDGConnectionError': <type at remote 0x1a511f8>, 'subprocess': <module at remote 0x7fbbdf73e1d8>, 'html': <module at remote 0x7fbbe04b5a58>, 'printerr': <function at remote 0x7fbbddf21a68>, 'DdgCmd': <type at remote 0x1a56968>, 'require_keywords': <function at remote 0x7fbbddf26f70>, 'completer_run': <function at remote 0x7fbbddf2d3f0>, 'sys': <module at remote 0x...(truncated), locals={'COLORMAP': {'X': '\x1b[1m', 'f': '\x1b[35m', 'K': '\x1b[92;1m', 'O': '\x1b[96;1m', 'm': '\x1b[94m', 'B': '\x1b[31;1m', 'g': '\x1b[36m', 'P': '\x1b[97;1m', 'c': '\x1b[32m', 'J': '\x1b[91;1m', 'F': '\x1b[35;1m', 'D': '\x1b[33;1m', 'A': '\x1b[30;1m', 'n': '\x1b[95m', 'k': '\x1b[92m', 'i': '\x1b[90m', 'j': '\x1b[91m', 'L': '\x1b[93;1m', 'G': '\x1b[36;1m', 'E': '\x1b[34;1m', 'C': '\x1b[32;1m', 'p': '\x1b[97m', 'd': '\x1b[33m', 'M': '\x1b[94;1m', 'H': '\x1b[37;1m', 'e': '\x1b[34m', 'y': '\x1b[7m', 'N': '\x1b[95;1m', 'Y': '\x1b[7;1m', 'a': '\x1b[30m', 'l': '\x1b[93m', 'o': '\x1b[96m', 'x': '\x1b[0m', 'b': '\x1b[31m', 'h': '\x1b[37m', 'I': '\x1b[90;1m'}, 'DDGConnectionError': <type at remote 0x1a511f8>, 'subprocess': <module at remote 0x7fbbdf73e1d8>, 'html': <module at remote 0x7fbbe04b5a58>, 'printerr': <function at remote 0x7fbbddf21a68>, 'DdgCmd': <type at remote 0x1a56968>, 'require_keywords': <function at remote 0x7fbbddf26f70>, 'completer_run': <function at remote 0x7fbbddf2d3f0>, 'sys': <module at remote 0x...(truncated), flags=0x7fff0e36d620, arena=0x1680a70) at ../Python/pythonrun.c:2180

21 0x00000000004276c5 in PyRun_FileExFlags (fp=0x16a9300,

filename_str=0x7fbbe083a4d0 "/home/bkerin/local/bin/ddgr", start=257,
globals={'COLORMAP': {'X': '\x1b[1m', 'f': '\x1b[35m', 'K':

'\x1b[92;1m', 'O': '\x1b[96;1m', 'm': '\x1b[94m', 'B': '\x1b[31;1m', 'g': '\x1b[36m', 'P': '\x1b[97;1m', 'c': '\x1b[32m', 'J': '\x1b[91;1m', 'F': '\x1b[35;1m', 'D': '\x1b[33;1m', 'A': '\x1b[30;1m', 'n': '\x1b[95m', 'k': '\x1b[92m', 'i': '\x1b[90m', 'j': '\x1b[91m', 'L': '\x1b[93;1m', 'G': '\x1b[36;1m', 'E': '\x1b[34;1m', 'C': '\x1b[32;1m', 'p': '\x1b[97m', 'd': '\x1b[33m', 'M': '\x1b[94;1m', 'H': '\x1b[37;1m', 'e': '\x1b[34m', 'y': '\x1b[7m', 'N': '\x1b[95;1m', 'Y': '\x1b[7;1m', 'a': '\x1b[30m', 'l': '\x1b[93m', 'o': '\x1b[96m', 'x': '\x1b[0m', 'b': '\x1b[31m', 'h': '\x1b[37m', 'I': '\x1b[90;1m'}, 'DDGConnectionError': <type at remote 0x1a511f8>, 'subprocess': <module at remote 0x7fbbdf73e1d8>, 'html': <module at remote 0x7fbbe04b5a58>, 'printerr': <function at remote 0x7fbbddf21a68>, 'DdgCmd': <type at remote 0x1a56968>, 'require_keywords': <function at remote 0x7fbbddf26f70>, 'completer_run': <function at remote 0x7fbbddf2d3f0>, 'sys': <module at remote 0x...(truncated), locals={'COLORMAP': {'X': '\x1b[1m', 'f': '\x1b[35m', 'K': '\x1b[92;1m', 'O': '\x1b[96;1m', 'm': '\x1b[94m', 'B': '\x1b[31;1m', 'g': '\x1b[36m', 'P': '\x1b[97;1m', 'c': '\x1b[32m', 'J': '\x1b[91;1m', 'F': '\x1b[35;1m', 'D': '\x1b[33;1m', 'A': '\x1b[30;1m', 'n': '\x1b[95m', 'k': '\x1b[92m', 'i': '\x1b[90m', 'j': '\x1b[91m', 'L': '\x1b[93;1m', 'G': '\x1b[36;1m', 'E': '\x1b[34;1m', 'C': '\x1b[32;1m', 'p': '\x1b[97m', 'd': '\x1b[33m', 'M': '\x1b[94;1m', 'H': '\x1b[37;1m', 'e': '\x1b[34m', 'y': '\x1b[7m', 'N': '\x1b[95;1m', 'Y': '\x1b[7;1m', 'a': '\x1b[30m', 'l': '\x1b[93m', 'o': '\x1b[96m', 'x': '\x1b[0m', 'b': '\x1b[31m', 'h': '\x1b[37m', 'I': '\x1b[90;1m'}, 'DDGConnectionError': <type at remote 0x1a511f8>, 'subprocess': <module at remote 0x7fbbdf73e1d8>, 'html': <module at remote 0x7fbbe04b5a58>, 'printerr': <function at remote 0x7fbbddf21a68>, 'DdgCmd': <type at remote 0x1a56968>, 'require_keywords': <function at remote 0x7fbbddf26f70>, 'completer_run': <function at remote 0x7fbbddf2d3f0>, 'sys': <module at remote 0x...(truncated), closeit=1, flags=0x7fff0e36d620) at ../Python/pythonrun.c:2133

22 0x00000000004255dc in PyRun_SimpleFileExFlags (fp=0x16a9300,

filename=0x7fbbe083a4d0 "/home/bkerin/local/bin/ddgr", closeit=1,
flags=0x7fff0e36d620) at ../Python/pythonrun.c:1606

23 0x00000000004243d9 in PyRun_AnyFileExFlags (fp=0x16a9300,

filename=0x7fbbe083a4d0 "/home/bkerin/local/bin/ddgr", closeit=1,
flags=0x7fff0e36d620) at ../Python/pythonrun.c:1292

24 0x000000000043eee6 in run_file (fp=0x16a9300,

filename=0x1641310 L"/home/bkerin/local/bin/ddgr", p_cf=0x7fff0e36d620)
at ../Modules/main.c:319

25 0x000000000043fc7c in Py_Main (argc=4, argv=0x1640020)

at ../Modules/main.c:751

26 0x000000000041e67f in main (argc=4, argv=0x7fff0e36d8a8)

at ../Modules/python.c:69

On 11/9/17, Arun Prakash Jana notifications@github.com wrote:

I believe the answer lies in the core dump. Can you share the backtrace from it?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jarun/ddgr/issues/20#issuecomment-343384524

jarun commented 6 years ago

It's the correct procedure. Also, the top 3 frames show that readline is invoked to handle the input and it fails:

#1  0x00007fbbde1ab92e in rl_callback_read_char ()
   from /lib/x86_64-linux-gnu/libreadline.so.6
#2  0x00007fbbde3cd0b2 in readline_until_enter_or_signal (
    prompt=0x7fbbddf2ec40 "\033[7mddgr (? for help)\033[0m ",
    signal=0x7fff0e366d98)
    at /scratch/packages/python/3.4/python3.4-3.4.2/Modules/readline.c:1103
#3  0x00007fbbde3cd203 in call_readline (
    sys_stdin=0x7fbbe0d0a4e0 <_IO_2_1_stdin_>,
    sys_stdout=0x7fbbe0d0a2a0 <_IO_2_1_stdout_>,
    prompt=0x7fbbddf2ec40 "\033[7mddgr (? for help)\033[0m ")
    at /scratch/packages/python/3.4/python3.4-3.4.2/Modules/readline.c:1191
...

The 3 params passed over from the python subsystem (stdin, stdout and prompt string) have nothing unusual in them (stdin and stdout are from the env without any modifications and the prompt is a simple string). I believe this has to be looked into by the readline team for further info on what's going wrong.

jarun commented 6 years ago

What happens if you comment out the import readline block towards the top of the ddgr file?

diff --git a/ddgr b/ddgr
index df6802d..df9ae91 100755
--- a/ddgr
+++ b/ddgr
@@ -29,10 +29,12 @@ import sys
 import textwrap
 import urllib.parse
 from urllib3.util import parse_url
+'''
 try:
     import readline
 except ImportError:
     pass
+'''
 import webbrowser

 # Basic setup
bkerin commented 6 years ago

Then the problem isn't triggerable, I guess because the stuff in ~/.inputrc doesn't apply (or I don't know how to make it apply anyway).

I tried typing in the stuff that C-q expands to in the inputrc (.exit\n(save=no)\n) but that doesn't reproduce the problem. Maybe I didn't type in quite the right expansion though, I'm not sure.

On 11/9/17, Arun Prakash Jana notifications@github.com wrote:

What happens if you comment out the import readline block towards the top of the ddgr file?

diff --git a/ddgr b/ddgr
index df6802d..df9ae91 100755
--- a/ddgr
+++ b/ddgr
@@ -29,10 +29,12 @@ import sys
 import textwrap
 import urllib.parse
 from urllib3.util import parse_url
+'''
 try:
     import readline
 except ImportError:
     pass
+'''
 import webbrowser

 # Basic setup

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jarun/ddgr/issues/20#issuecomment-343391833

jarun commented 6 years ago

That isolates the problem to the GNU readline library. I believe you can reproduce it easily without ddgr. Write a simple 3-line python3 script, import readline and call input('somestring ').

#!/usr/bin/env python3

import readline

input('myprompt: ')
bkerin commented 6 years ago

yep, same behavior. I've only ever seen this behavior with the python interface (which is not to say it isn't a readline bug). If submitted it as a bug against python3.4 with a note that it's likely a readline bug (though I've never triggered it with any other readline-using app).

On 11/10/17, Arun Prakash Jana notifications@github.com wrote:

That isolates the problem to the GNU readline library. I believe you can reproduce it easily without ddgr. Write a simple python3 script, import readline and call input('somestring ').

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/jarun/ddgr/issues/20#issuecomment-343520139

jarun commented 6 years ago

:+1: