Subject: 26.1; url-retrieve-synchronously possible race condition

From: Ernesto Alfonso <[email-masked]>
Date: Thu, 16 Jan 2020 17:04:06 -0800

url-retrieve-synchronously unexpectedly returns an empty buffer:

emacs -Q --eval '(with-current-buffer (url-retrieve-synchronously "
https://google.com") (print (buffer-string)))' --batch
Contacting host: google.com:443

""

If I add (sit-for 2) in url-retrieve-synchronously after the (url-retrieve
...) call:

    (setq asynch-buffer
     (url-retrieve url (lambda (&rest ignored)
         (url-debug 'retrieval "Synchronous fetching done (%S)"
(current-buffer))
         (setq retrieval-done t
       asynch-buffer (current-buffer)))
    nil silent inhibit-cookies))
    (sit-for 2)

then I see the expected output.

In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5)
 of 2019-09-22, modified by Debian built on x86-grnet-01
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux 10 (buster)

Recent messages:
var a=window.location,b=a.href.indexOf(\"#\");if(0<=b){var
c=a.href.substring(b+1);/(^|&)q=/.test(c)&&-1==c.indexOf(\"#\")&&a.replace(\"/search?\"+c.replace(/(^|&)fp=[^&]*/g,\"\")+\"&cad=h\")};</script><style>#gbar,#guser{font-size:13px;padding-top:1px
!important;}#gbar{height:22px}#guser{padding-bottom:7px
!important;text-align:right}.gbh,.gbd{border-top:1px solid
#c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media
all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline
!important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27
!important}.gbf .gb4{color:#900 !important}
</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px
8px 0}td{line-height:.8em}.gac_m
td{line-height:17px}form{margin-bottom:20px}.h{color:#36c}.q{color:#00c}.ts
td{padding:0}.ts{border-collapse:collapse}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px
arial,sans-serif}.gsfs{font:17px
arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0
4px;margin-left:4px}input{font-family:inherit}a.gb1,a.gb2,a.gb3,a.gb4{color:#11c
!important}body{background:#fff;color:black}a{color:#11c;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl
a{color:#36c}a:visited{color:#551a8b}a.gb1,a.gb4{text-decoration:underline}a.gb3:hover{text-decoration:none}#ghead
a.gb2:hover{color:#fff !important}.sblc{padding-top:5px}.sblc
a{display:block;margin:2px
0;margin-left:13px;font-size:11px}.lsbb{background:#eee;border:solid
1px;border-color:#ccc #999 #999
#ccc;height:30px}.lsbb{display:block}.ftl,#fll
a{display:inline-block;margin:0
12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px
repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px
arial,sans-serif;vertical-align:top}.lsb:active{background:#ccc}.lst:focus{outline:none}</style><script
nonce=\"K1ZTyt1eFX1+5QgukFeIxg==\"></script></head><body
bgcolor=\"#fff\"><script nonce=\"K1ZTyt1eFX1+5QgukFeIxg==\">(function(){var
src='/images/nav_logo229.png';var iesg=false;document.body.onload =
function(){window.n && window.n();if (document.images){new Image().src=src;}
if
(!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}
}
})();</script><div id=\"mngb\"> <div id=gbar><nobr><b class=gb1>Search</b>
<a class=gb1 href=\"https://www.google.com/imghp?hl=en&tab=wi\">Images</a>
<a class=gb1 href=\"https://maps.google.com/maps?hl=en&tab=wl\">Maps</a> <a
class=gb1 href=\"https://play.google.com/?hl=en&tab=w8\">Play</a> <a
class=gb1 href=\"https://www.youtube.com/?gl=US&tab=w1\">YouTube</a> <a
class=gb1 href=\"https://news.google.com/nwshp?hl=en&tab=wn\">News</a> <a
class=gb1 href=\"https://mail.google.com/mail/?tab=wm\">Gmail</a> <a
class=gb1 href=\"https://drive.google.com/?tab=wo\">Drive</a> <a class=gb1
style=\"text-decoration:none\" href=\"
https://www.google.com/intl/en/about/products?tab=wh\"><u>More</u>
&raquo;</a></nobr></div><div id=guser width=100%><nobr><span id=gbn
class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a
href=\"http://www.google.com/history/optout?hl=en\" class=gb4>Web
History</a> | <a  href=\"/preferences?hl=en\" class=gb4>Settings</a> | <a
target=_top id=gb_70 href=\"
https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/\"
class=gb4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div
class=gbh style=right:0></div> </div><center><br clear=\"all\"
id=\"lgpd\"><div id=\"lga\"><img alt=\"Google\" height=\"92\"
src=\"/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png\"
style=\"padding:28px 0 14px\" width=\"272\"
id=\"hplogo\"><br><br></div><form action=\"/search\" name=\"f\"><table
cellpadding=\"0\" cellspacing=\"0\"><tr valign=\"top\"><td
width=\"25%\">&nbsp;</td><td align=\"center\" nowrap=\"\"><input
name=\"ie\" value=\"ISO-8859-1\" type=\"hidden\"><input value=\"en\"
name=\"hl\" type=\"hidden\"><input name=\"source\" type=\"hidden\"
value=\"hp\"><input name=\"biw\" type=\"hidden\"><input name=\"bih\"
type=\"hidden\"><div class=\"ds\" style=\"height:32px;margin:4px 0\"><input
class=\"lst\" style=\"color:#000;margin:0;padding:5px 8px 0
6px;vertical-align:top\" autocomplete=\"off\" value=\"\" title=\"Google
Search\" maxlength=\"2048\" name=\"q\" size=\"57\"></div><br
style=\"line-height:0\"><span class=\"ds\"><span class=\"lsbb\"><input
class=\"lsb\" value=\"Google Search\" name=\"btnG\"
type=\"submit\"></span></span><span class=\"ds\"><span
class=\"lsbb\"><input class=\"lsb\" id=\"tsuid1\" value=\"I'm Feeling
Lucky\" name=\"btnI\" type=\"submit\"><script
nonce=\"K1ZTyt1eFX1+5QgukFeIxg==\">(function(){var
id='tsuid1';document.getElementById(id).onclick = function(){if
(this.form.q.value){this.checked = 1;if
(this.form.iflsig)this.form.iflsig.disabled = false;}
else top.location='/doodles/';};})();</script><input
value=\"AAP1E1EAAAAAXiA41glQfyPBIn0ZwjCe2x8VAbECMoJ0\" name=\"iflsig\"
type=\"hidden\"></span></span></td><td class=\"fl sblc\" align=\"left\"
nowrap=\"\" width=\"25%\"><a
href=\"/advanced_search?hl=en&amp;authuser=0\">Advanced
search</a></td></tr></table><input id=\"gbv\" name=\"gbv\" type=\"hidden\"
value=\"1\"><script nonce=\"K1ZTyt1eFX1+5QgukFeIxg==\">(function(){var
a,b=\"1\";if(document&&document.getElementById)if(\"undefined\"!=typeof
XMLHttpRequest)b=\"2\";else if(\"undefined\"!=typeof ActiveXObject){var
c,d,e=[\"MSXML2.XMLHTTP.6.0\",\"MSXML2.XMLHTTP.3.0\",\"MSXML2.XMLHTTP\",\"Microsoft.XMLHTTP\"];for(c=0;d=e[c++];)try{new
ActiveXObject(d),b=\"2\"}catch(h){}}a=b;if(\"2\"==a&&-1==location.search.indexOf(\"&gbv=2\")){var
f=google.gbvu,g=document.getElementById(\"gbv\");g&&(g.value=a);f&&window.setTimeout(function(){location.href=f},0)};}).call(this);</script></form><div
id=\"gac_scont\"></div><div
style=\"font-size:83%;min-height:3.5em\"><br></div><span id=\"footer\"><div
style=\"font-size:10pt\"><div style=\"margin:19px auto;text-align:center\"
id=\"fll\"><a href=\"/intl/en/ads/\">Advertising Programs</a><a
href=\"/services/\">Business Solutions</a><a
href=\"/intl/en/about.html\">About Google</a></div></div><p
style=\"color:#767676;font-size:8pt\">&copy; 2020 - <a
href=\"/intl/en/policies/privacy/\">Privacy</a> - <a
href=\"/intl/en/policies/terms/\">Terms</a></p></span></center><script
nonce=\"K1ZTyt1eFX1+5QgukFeIxg==\">(function(){window.google.cdo={height:0,width:0};(function(){var
a=window.innerWidth,b=window.innerHeight;if(!a||!b){var
c=window.document,d=\"CSS1Compat\"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.log(\"\",\"\",\"/client_204?&atyp=i&biw=\"+a+\"&bih=\"+b+\"&ei=\"+google.kEI);}).call(this);})();(function(){var
u='/xjs/_/js/k\\x3dxjs.hp.en_US.EEnQC-n84dQ.O/m\\x3dsb_he,d/am\\x3dAAMCbAQ/d\\x3d1/rs\\x3dACT90oFqnO1Ho8c2SBYOwbTA4IzkV7C2Cw';
setTimeout(function(){var b=document;var
a=\"SCRIPT\";\"application/xhtml+xml\"===b.contentType&&(a=a.toLowerCase());a=b.createElement(a);a.src=u;google.timers&&google.timers.load&&google.tick&&google.tick(\"load\",\"xjsls\");document.body.appendChild(a)},0);})();(function(){window.google.xjsu='/xjs/_/js/k\\x3dxjs.hp.en_US.EEnQC-n84dQ.O/m\\x3dsb_he,d/am\\x3dAAMCbAQ/d\\x3d1/rs\\x3dACT90oFqnO1Ho8c2SBYOwbTA4IzkV7C2Cw';})();function
_DumpException(e){throw e;}
function _F_installCss(c){}
(function(){google.spjs=false;google.snet=true;google.em=[];google.emw=false;})();(function(){var
pmc='{\\x22d\\x22:{},\\x22sb_he\\x22:{\\x22agen\\x22:true,\\x22cgen\\x22:true,\\x22client\\x22:\\x22heirloom-hp\\x22,\\x22dh\\x22:true,\\x22dhqt\\x22:true,\\x22ds\\x22:\\x22\\x22,\\x22ffql\\x22:\\x22en\\x22,\\x22fl\\x22:true,\\x22host\\x22:\\
x22google.com\\x22,\\x22isbh\\x22:28,\\x22jsonp\\x22:true,\\x22msgs\\x22:{\\x22cibl\\x22:\\x22Clear
Search\\x22,\\x22dym\\x22:\\x22Did you
mean:\\x22,\\x22lcky\\x22:\\x22I\\\\u0026#39;m Feeling
Lucky\\x22,\\x22lml\\x22:\\x22Learn more\\x22,\\x22oskt\\x22:\\x22Input
tools\\x22,\\x22psrc\\x22:\\x22This search was removed from your \\\\u003Ca
href\\x3d\\\\\\x22/history\\\\\\x22\\\\u003EWeb
History\\\\u003C/a\\\\u003E\\x22,\\x22psrl\\x22:\\x22Remove\\x22,\\x22sbit\\x22:\\x22Search
by image\\x22,\\x22srch\\x22:\\x22Google
Search\\x22},\\x22ovr\\x22:{},\\x22pq\\x22:\\x22\\x22,\\x22refpd\\x22:true,\\x22rfs\\x22:[],\\x22sbpl\\x22:16,\\x22sbpr\\x22:16,\\x22scd\\x22:10,\\x22stok\\x22:\\x22HBbSDogqmpO62Csuyabk52C95pI\\x22,\\x22uhde\\x22:false}}';google.pmc=JSON.parse(pmc);})();</script>
       </body></html>"
completing-read-default: Command attempted to use minibuffer while in
minibuffer
Quit [2 times]
Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
 --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs-StqULU/emacs-26.1+1=.
-fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  text-scale-mode: t
  diff-auto-refine-mode: t
  hi-lock-mode: t
  global-erjoalgo-command-mode: t
  erjoalgo-command-mode: t
  company-mode: t
  show-paren-mode: t
  global-text-scale-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/ealfonso/quicklisp/dists/quicklisp/software/slime-v2.24/slime-tests
hides /home/ealfonso/.emacs.d/elpa/slime-20191224.2328/slime-tests
/home/ealfonso/quicklisp/dists/quicklisp/software/slime-v2.24/slime-autoloads
hides /home/ealfonso/.emacs.d/elpa/slime-20191224.2328/slime-autoloads
/home/ealfonso/quicklisp/dists/quicklisp/software/slime-v2.24/slime hides
/home/ealfonso/.emacs.d/elpa/slime-20191224.2328/slime
/home/ealfonso/git/autobuild/autobuild hides
/home/ealfonso/git/dotemacs/lisp/core/autobuild
/home/ealfonso/.emacs.d/elpa/s-20180406.808/s hides
/home/ealfonso/git/dotemacs/lisp/libs/s
/home/ealfonso/.emacs.d/elpa/dash-20191109.1327/dash hides
/home/ealfonso/git/dotemacs/lisp/libs/dash
/home/ealfonso/quicklisp/dists/quicklisp/software/slime-v2.24/contrib/slime-cl-indent
hides /home/ealfonso/git/dotemacs/lisp/libs/slime-cl-indent

Features:
(shadow sort mailalias mail-extr emacsbug misearch multi-isearch
face-remap ffap vc-git diff-mode cl-print diary-lib diary-loaddefs
cal-iso org-rmail org-mhe org-irc org-info org-gnus nnir gnus-sum
gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source
utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range gnus-win
org-docview doc-view jka-compr image-mode org-bibtex bibtex org-bbdb
org-w3m org-agenda files-x tmp-completions tetris-o-1 beeper translation
babel mm-url gnus nnheader wm-windows slime-fancy slime-trace-dialog
slime-fontifying-fu slime-package-fu slime-references
slime-compiler-notes-tree slime-scratch slime-presentations bridge
slime-macrostep macrostep slime-mdot-fu slime-enclosing-context
slime-fuzzy slime-fancy-trace slime-fancy-inspector slime-c-p-c
slime-editing-commands slime-autodoc slime-repl elp slime-parse slime
hi-lock company-oddmuse company-keywords company-etags company-gtags
company-dabbrev-code company-dabbrev company-files company-capf
company-cmake company-xcode company-clang company-semantic company-eclim
company-template company-bbdb elec-pair lisp-mnt gud apropos compile
etags xref project arc-mode archive-mode hyperspec browse-url ox-texinfo
ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn
nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar
ox-html table ox-ascii ox-publish ox org-crypt org-element avl-tree
generator org org-macro org-footnote org-pcomplete pcomplete org-list
org-faces org-entities noutline outline org-version ob-emacs-lisp ob
ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint comint
ring ob-core ob-eval org-compat org-macs org-loaddefs cal-menu calendar
cal-loaddefs erc-goodies erc erc-backend erc-compat thingatpt warnings
mm-archive network-stream starttls url-http tls gnutls url-gw nsm
url-cache url-auth url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util mailcap bbdb-mua bbdb-com crm
bbdb-message sendmail message rmc puny dired dired-loaddefs format-spec
rfc822 mml mml-sec epa derived epg gnus-util rmail rmail-loaddefs
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader bbdb
bbdb-site timezone cus-edit cus-start cus-load wid-edit selcand
proxy-mode project-opener org-omnibar erjoalgo-command-mode
command-mode-commands anonymizer genpass ert pp ewoc debug
autobuild-examples autobuild flycheck cl-extra ansi-color json map
find-func help-mode rx subr-x header2 sticky-windows company edmacro
kmacro pcase dedicated dash-functional plusx my-emacs-settings paren
server isearch-fast-reverse buttons zoom-global easy-mmode quick-yes
advice goto-last-change f dash s finder-inf slime-autoloads info cl
package easymenu epg-config url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache url-vars seq
byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 756814 34360)
 (symbols 48 57815 1)
 (miscs 40 371 724)
 (strings 32 216401 1715)
 (string-bytes 1 5916797)
 (vectors 16 66163)
 (vector-slots 8 1863704 71522)
 (floats 8 317 616)
 (intervals 56 1674 208)
 (buffers 992 37))