Closed mika76 closed 2 years ago
@mika76, this doesn't seem to be related to LaunchBrowser, as any external request fails for me. redbean 1.5 works on older versions (Mac Mini 2012 - Intel i7 - 10.15.7), but doesn't work on a newer one (MacBook Pro 2021 14” - M1 Max - macOS 12.0.1). I suspect it may be related to Rosetta emulation, but I'm not sure if it's used in your case or not (it's used in mine on 12.0.1).
@jart, here is the full crash report:
error: Uncaught SIGSEGV (SEGV_MAPERR) on starlight pid 2216
./redbean-crash-debug.com
ENOENT[No such file or directory][2]
100080020c80 0000005458c5 NULL+0
70000001eef0 000000000000 NULL+0
70000001ff10 000000421d2f NULL+0
70000001ffc0 000000402832 NULL+0
70000001ffe0 000000402ab0 NULL+0
0001045df7b0 00000040225f NULL+0
RAX ffffffffffffffff RBX 00000001004ea088 RDI 00000001004ea088 ST(0) -18437520701672696841.18446744073709550808
RCX 000070000001ec78 RDX 00000001004ea3f0 RSI 0000000000000001 ST(1) -18437520701672696841.18446744073709550808
RBP 000070000001eef0 RSP 000070000001eb20 RIP 00000000005458c5 ST(2) -18437520701672696841.18446744073709550808
R8 00000000005ceea8 R9 cccccccccccccccd R10 0000000000000006 ST(3) -18437520701672696841.18446744073709550808
R11 0000000002000000 R12 0000000000000001 R13 0000000000000004 ST(4) -18437520701672696841.18446744073709550808
R14 0000000000000004 R15 0000000000001f90 CF VF PF ZF IF PE
XMM0 67756265642d68736172632d6e616562 XMM8 00000001c6e415960000000154442bd4
XMM1 65642d68736172632d6e616562646572 XMM9 59593272149eb14905bf6caca2976374
XMM2 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e XMM10 00000000000000000000000000000000
XMM3 00000000000000000000000000000000 XMM11 00000000000000000000000000000000
XMM4 000000000000000000000000000000de XMM12 00000000000000000000000000000000
XMM5 000000000000000000000000619f35b8 XMM13 00000000000000000000000000000000
XMM6 0000100080066a600000100080071290 XMM14 00000000000000000000000000000000
XMM7 64cb9d63950793198b62c873f0cfed49 XMM15 00000000000000000000000000000000
100080000000-100080050000 rw-pa-- 5x automap
100080050000-100080060000 rw-sa-- 1x automap
100080060000-1000800a0000 rw-pa-- 4x automap w/ 19 frame hole
1000801d0000-1000801f0000 r--sf-- 2x automap
1000801f0000-1000803a0000 r--pf-- 27x automap
6ffffffe0000-700000020000 rw-pa-F 4x stack
# 43 frames mapped w/ 19 frames gapped
./redbean-crash-debug.com
I did a bit of troubleshooting and it looks like it's crashing in the HandlePoll
function and it looks like it doesn't come back from the signal handler correctly. I'm not sure how to debug it further. I tried to run it with a debug build, but ran into a different issue trying to launch redbean:
libc/intrin/asan.c:1147: assert(!OverlapsShadowSpace((void *)p, n)) failed
[1] 13239 segmentation fault bash ./redbean-dbg.com
@pkulchenko My macbook is a 2019 x86 based one - not m1 so I don't think it's rosetta in my case...
Do you get the same SIGSEGV when you access the URL without LaunchBrowser command?
With just a single LaunchBrowser()
command...
error: Uncaught SIGSEGV (SEGV_MAPERR) on Mladens-MBP pid 28577
./redbean.com
ENOENT[No such file or directory][2]
100080020830 00000041c54a NULL+0
70000001ff90 00000042191b NULL+0
70000001ffc0 000000421b7f NULL+0
70000001ffe0 00000040296e NULL+0
7ffeefbff690 00000040217c NULL+0
RAX 0000000000000000 RBX 0000100080035730 RDI 0000100080035730 ST(0) -18437520701672696841.18446744073709550808
RCX 0000000000000000 RDX 0000000000000001 RSI 0000000000000020 ST(1) 0.0
RBP 000070000001ff90 RSP 000070000001fe80 RIP 000000000041c54a ST(2) 0.0
R8 0000100080081ca0 R9 0000000000001be0 R10 0000100080081c90 ST(3) 0.0
R11 0000100080000000 R12 00007ffeefbff6d0 R13 00007ffeefbff6d0 ST(4) 0.0
R14 00007ffeefbff6e8 R15 00007ffeefbff6a0 VF PF IF PE
XMM0 00000000000000000000000000000000 XMM8 0000000000000000e7b10ffda7d81ffe
XMM1 6e6165626465722f74656e2f6c6f6f74 XMM9 21d86ddf11b27ede68bfcb424445e631
XMM2 6165626465722f2e0000000000006d6f XMM10 ffffffffffffffff0b0a090803020100
XMM3 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e XMM11 44d0016daff1ce0a0000000000000000
XMM4 b0a2ddb4f72c2f491e008a055c2bd42b XMM12 0b0a090803020100ffffffffffffffff
XMM5 09d25ffe364fa7f9de897b5c14ac7632 XMM13 0c0d0e0f08090a0b0405060700010203
XMM6 0000100080070f200000100080071220 XMM14 8dfcea526a1dcef704db99f745b00101
XMM7 f077c0ed882d08620f19b0bc0801ca42 XMM15 3e2d3d5ffebdff9464b8c6297bad293c
100080000000-100080050000 rw-pa-- 5x automap
100080050000-100080060000 rw-sa-- 1x automap
100080060000-1000800a0000 rw-pa-- 4x automap w/ 17 frame hole
1000801b0000-1000801e0000 r--sf-- 3x automap
1000801e0000-100080380000 r--pf-- 26x automap
6ffffffe0000-700000020000 ---pa-F 4x stack
# 43 frames mapped w/ 17 frames gapped
./redbean.com -v
Do you get the same SIGSEGV when you access the URL without LaunchBrowser command?
Nope - works fine - although I've only just started playing with redbean so I haven't tried much...
@mika76, interesting; can you launch the same command with -vvv options? there should be some additional information in the logs from the LaunchBrowser command. Also, does it actually launch the browser?
➜ redbean bash -c './redbean.com -vvv'
D2021-12-07T12:41:15.482715:tool/net/redbean.c:5341:redbean:29109] (lua) LuaRun("/.init.lua")
I2021-12-07T12:41:15+000109:tool/net/redbean.c:6700:redbean:29109] (srvr) listen http://127.0.0.1:8080
I2021-12-07T12:41:15+000018:tool/net/redbean.c:6700:redbean:29109] (srvr) listen http://192.168.50.202:8080
I2021-12-07T12:41:15+000014:tool/net/redbean.c:6700:redbean:29109] (srvr) listen http://10.211.55.2:8080
I2021-12-07T12:41:15+000014:tool/net/redbean.c:6700:redbean:29109] (srvr) listen http://10.37.129.2:8080
V2021-12-07T12:41:15+001104:tool/net/redbean.c:1709:redbean:29109] (ssl) could not find non-CA SSL certificate key pair with -addext keyUsage=digitalSignature -addext extendedKeyUsage=serverAuth
V2021-12-07T12:41:15+000003:tool/net/redbean.c:1712:redbean:29109] (ssl) could not find CA key signing key pair with -addext keyUsage=keyCertSign
V2021-12-07T12:41:15+000001:tool/net/redbean.c:1714:redbean:29109] (ssl) generating self-signed ssl certificates
D2021-12-07T12:41:15+000850:net/https/logcertificate.c:28:redbean:29109] generated EC certificate
cert. version : 3
serial number : D4:A8:7E:CB:1C:03:20:44:63:2A:F3:4D:C5:75:71:39
issuer name : CN=localhost
subject name : CN=localhost
issued on : 2021-12-06 20:41:15
expires on : 2022-12-08 20:41:15
signed using : ECDSA with SHA256
EC key size : 256 bits
basic constraints : CA=false
subject alt name :
dNSName : localhost
dNSName : kubernetes.docker.internal
dNSName : ocsp.apple.com
iPAddress : 127.0.0.1
iPAddress : 192.168.50.202
iPAddress : 10.211.55.2
iPAddress : 10.37.129.2
key usage : Digital Signature
ext key usage : TLS Web Server Authentication, TLS Web Client Authentication
V2021-12-07T12:41:15+002179:tool/net/redbean.c:574:redbean:29109] (ssl) using EC certificate "CN=localhost" for HTTPS server
D2021-12-07T12:41:15+090299:net/https/logcertificate.c:28:redbean:29109] generated RSA certificate
cert. version : 3
serial number : EF:81:EB:8C:E9:7F:73:72:98:23:BA:3E:05:CE:A7:63
issuer name : CN=localhost
subject name : CN=localhost
issued on : 2021-12-06 20:41:15
expires on : 2022-12-08 20:41:15
signed using : RSA with SHA-256
RSA key size : 2048 bits
basic constraints : CA=false
subject alt name :
dNSName : localhost
dNSName : kubernetes.docker.internal
dNSName : ocsp.apple.com
iPAddress : 127.0.0.1
iPAddress : 192.168.50.202
iPAddress : 10.211.55.2
iPAddress : 10.37.129.2
key usage : Digital Signature, Key Encipherment
ext key usage : TLS Web Server Authentication, TLS Web Client Authentication
V2021-12-07T12:41:15+000014:tool/net/redbean.c:574:redbean:29109] (ssl) using RSA certificate "CN=localhost" for HTTPS server
error: Uncaught SIGSEGV (SEGV_MAPERR) on Mladens-MBP pid 29109
./redbean.com
ENOENT[No such file or directory][2]
100080020830 00000041c54a NULL+0
70000001ff90 00000042191b NULL+0
70000001ffc0 000000421b7f NULL+0
70000001ffe0 00000040296e NULL+0
7ffeefbff690 00000040217c NULL+0
RAX 0000000000000000 RBX 0000100080035730 RDI 0000100080035730 ST(0) -18437520701672696841.18446744073709550808
RCX 0000000000000000 RDX 0000000000000004 RSI 0000000000000020 ST(1) 0.0
RBP 000070000001ff90 RSP 000070000001fe80 RIP 000000000041c54a ST(2) 0.0
R8 0000100080081a70 R9 0000000000001e10 R10 0000100080081a60 ST(3) 0.0
R11 0000100080000000 R12 00007ffeefbff6d0 R13 00007ffeefbff6d0 ST(4) 0.0
R14 00007ffeefbff6e8 R15 00007ffeefbff6a0 VF PF IF PE
XMM0 00000000000000000000000000000000 XMM8 00000000000000008b188ba17b7b6da1
XMM1 6e6165626465722f74656e2f6c6f6f74 XMM9 26ef842d21b77c64d7b3e8b49eb20182
XMM2 6165626465722f2e0000000000006d6f XMM10 ffffffffffffffff0b0a090803020100
XMM3 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e XMM11 d2916703e0f67b870000000000000000
XMM4 2022c9cfade036a57eb613a150e7a7cd XMM12 0b0a090803020100ffffffffffffffff
XMM5 534c54202c6e6f6974616369746e6568 XMM13 0c0d0e0f08090a0b0405060700010203
XMM6 0000100080070f200000100080071220 XMM14 dc96f5aa5ccc5921771f4adfd56bd91e
XMM7 d454aabaef7580697c82dbbe312354a3 XMM15 750da810953ea67b58574e3016217957
100080000000-100080050000 rw-pa-- 5x automap
100080050000-100080060000 rw-sa-- 1x automap
100080060000-1000800a0000 rw-pa-- 4x automap w/ 17 frame hole
1000801b0000-1000801e0000 r--sf-- 3x automap
1000801e0000-100080380000 r--pf-- 26x automap
6ffffffe0000-700000020000 ---pa-F 4x stack
# 43 frames mapped w/ 17 frames gapped
./redbean.com -vvv
, does it actually launch the browser?
Nope, just crashes back to the prompt
Hm, there are not that many lines where it may fail, given that it doesn't even get to the DEBUGF
call:
if ((prog = commandv(GetSystemUrlLauncherCommand(), gc(malloc(PATH_MAX))))) {
u = gc(xasprintf("http://%s:%d%s", inet_ntoa(addr),
ntohs(serveraddr->sin_port), gc(EscapePath(path, -1, 0))));
DEBUGF("(srvr) opening browser with command %`'s %s", prog, u);
If you're compiling from source, can you add a couple of print statements inside LaunchBrowser to see where exactly it fails?
same on windows10
@mika76, @badiku, can you check if this patch fixes the issue: https://github.com/pkulchenko/cosmopolitan/tree/redbean-fix-browserlaunch? It does fix the issue for me on Windows, but the explorer still fails to launch with error code 5 returned and I can't yet figure out why.
@pkulchenko you pinged the wrong mika ;)
Ha, thanks; fixed.
@mika76, let me know if you had a chance to test the patch in https://github.com/jart/cosmopolitan/issues/337#issuecomment-1002434246 and if it worked for you; not sure if you saw the update. Thanks!
Hey @pkulchenko nah I haven't played with this since then - I'll see if I can try it out sometime and will post here...
Nice work, @pkulchenko -- your change 82d62e76fd6abc3b3edb840a814cb22f12f7ad05 corrected the LaunchBrowser()
problem for me on Ubuntu.
Thank you for checking! Submitted a PR #359.
I am seeing this issue on MacOs. calling LaunchBrowser('/foo')
from .init.lua
fails.
bash -c './redbean.com -vvmbag'
D2022-06-06T15:57:18.819283:tool/net/redbean.c:5341:redbean:72560] (lua) LuaRun("/.init.lua")
I2022-06-06T15:57:18+000242:tool/net/redbean.c:6700:redbean:72560] (srvr) listen http://127.0.0.1:8080
I2022-06-06T15:57:18+000083:tool/net/redbean.c:6700:redbean:72560] (srvr) listen http://172.20.20.20:8080
V2022-06-06T15:57:18+001427:tool/net/redbean.c:1709:redbean:72560] (ssl) could not find non-CA SSL certificate key pair with -addext keyUsage=digitalSignature -addext extendedKeyUsage=serverAuth
V2022-06-06T15:57:18+000007:tool/net/redbean.c:1712:redbean:72560] (ssl) could not find CA key signing key pair with -addext keyUsage=keyCertSign
V2022-06-06T15:57:18+000012:tool/net/redbean.c:1714:redbean:72560] (ssl) generating self-signed ssl certificates
D2022-06-06T15:57:18+031526:net/https/logcertificate.c:28:redbean:72560] generated EC certificate
cert. version : 3
serial number : 4F:50:DB:FC:1E:ED:7C:A0:E3:8F:8A:28:42:40:74:83
issuer name : CN=localhost
subject name : CN=localhost
issued on : 2022-06-05 22:57:18
expires on : 2023-06-07 22:57:18
signed using : ECDSA with SHA256
EC key size : 256 bits
basic constraints : CA=false
subject alt name :
dNSName : localhost
dNSName : localhost.localdomain
dNSName : local
dNSName : kubernetes.docker.internal
iPAddress : 127.0.0.1
iPAddress : 172.20.20.20
key usage : Digital Signature
ext key usage : TLS Web Server Authentication, TLS Web Client Authentication
V2022-06-06T15:57:18+000028:tool/net/redbean.c:574:redbean:72560] (ssl) using EC certificate "CN=localhost" for HTTPS server
D2022-06-06T15:57:19.009594:net/https/logcertificate.c:28:redbean:72560] generated RSA certificate
cert. version : 3
serial number : C1:28:B6:D2:C3:96:50:07:D6:9C:7F:C6:F4:8A:C2:A6
issuer name : CN=localhost
subject name : CN=localhost
issued on : 2022-06-05 22:57:19
expires on : 2023-06-07 22:57:19
signed using : RSA with SHA-256
RSA key size : 2048 bits
basic constraints : CA=false
subject alt name :
dNSName : localhost
dNSName : localhost.localdomain
dNSName : local
dNSName : kubernetes.docker.internal
iPAddress : 127.0.0.1
iPAddress : 172.20.20.20
key usage : Digital Signature, Key Encipherment
ext key usage : TLS Web Server Authentication, TLS Web Client Authentication
V2022-06-06T15:57:19+000028:tool/net/redbean.c:574:redbean:72560] (ssl) using RSA certificate "CN=localhost" for HTTPS server
error: Uncaught SIGSEGV (SEGV_MAPERR) on iains-MacBook-Pro pid 72560
./redbean.com
ENOSYS[Function not implemented][78]
100080020530 00000041c54a LaunchBrowser+44
70000001ff90 00000042191b RedBean+323
70000001ffc0 000000421b7f main+52
70000001ffe0 00000040296e cosmo+63
7ffeefbff8f0 00000040217c _start+113
RAX 0000000000000000 RBX 00001000800356d0 RDI 00001000800356d0 ST(0) -18437520701672696841.18446744073709550808
RCX 0000000000000000 RDX 0000000000000000 RSI 0000000000000020 ST(1) -18437520701672696841.18446744073709550808
RBP 000070000001ff90 RSP 000070000001fe80 RIP 000000000041c54a ST(2) 0.0
R8 0000100080082f60 R9 0000000000001e10 R10 0000100080082f50 ST(3) 0.0
R11 0000100080000000 R12 00007ffeefbff930 R13 00007ffeefbff930 ST(4) 0.0
R14 00007ffeefbff948 R15 00007ffeefbff900 VF IF PE
XMM0 00000000000000000000000000000000 XMM8 00000000000000000a7de383a57f050f
XMM1 6e6165626465722f74656e2f6c6f6f74 XMM9 8d8b5cfb0774170dba6a1fb398f55d74
XMM2 6165626465722f2e0000006d6f632e6e XMM10 ffffffffffffffff0b0a090803020100
XMM3 2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e XMM11 ef388fa3e510488a0000000000000000
XMM4 fa6b0e07f504a5d890405f7e2be1e450 XMM12 0b0a090803020100ffffffffffffffff
XMM5 534c54202c6e6f6974616369746e6568 XMM13 0c0d0e0f08090a0b0405060700010203
XMM6 000010008006d3c00000100080072290 XMM14 fb2edd7db49646c873ced0eeae6924a3
XMM7 9498780c5a3b140d5912406b9858f4d0 XMM15 5b147e7f2bfa2eca0265507265dbb626
100080000000-100080050000 rw-pa-- 5x automap
100080050000-100080060000 rw-sa-- 1x automap
100080060000-100080140000 rw-pa-- 14x automap w/ 7 frame hole
1000801b0000-1000801e0000 r--sf-- 3x automap
1000801e0000-100080380000 r--pf-- 26x automap
100080380000-100080490000 rw-pa-- 17x automap w/ 21 frame hole
1000805e0000-100080780000 rw-pa-- 26x automap
6ffffffe0000-700000020000 ---pa-F 4x stack
# 96 frames mapped w/ 28 frames gapped
I can confirm that just doing: open https://google.com
in my terminal works as expected, (opens browser at google.com), so not sure what the ENOSYS[Function not implemented][78]
might be. Happy to debug myself with a bit of direction if available.
This appears to be a slightly different issue. What version of Redbean are you using and did you download it or built yourself? Also, what version of macOS are you on? I may be able to check later today.
Redbean 1.5 from: curl https://redbean.dev/redbean-latest.com >redbean.com
macOS Big Sur version 11.6.5
MacBook Pro (Retina, 15-inch, Mid 2015)
2.2 GHz Quad-Core Intel Core i7
@imaitland, yes, that fix wasn't in 1.5, as it was introduced later, after 1.5 was already released.
redbean 1.5 macos big sur 11.6
If I add in an index.html file then it works fine and I get the server running, but as soon as I add the command
LaunchBrowser()
to the.init.lua
file, it fails with:I've tried with paths
"/"
and"/index.html"
and"index.html"
but they all fail with the same issue.