cosmopolitan icon indicating copy to clipboard operation
cosmopolitan copied to clipboard

[redbean] big POST Fetch() request fails with "tls write failed (UNKNOWN ERROR CODE (4000) -0xffffc000)"

Open elitepleb opened this issue 2 years ago • 3 comments

Using Fetch() to upload files with multipart/form-data encoding might not be it's intended use, but it's the situation i've found myself in.

It seems to fail at around 16kb, and setting a bigger ProgramMaxPayloadSize does not help.

Minimal reproduction with a public http dump service in interpreter mode Works Fetch('https://httpdump.app/dumps/{uuid}', {method="POST", body = "a" * (1024*16 - 155) }) Fails printing nil "tls write failed (UNKNOWN ERROR CODE (4000) -0xffffc000)" Fetch('https://httpdump.app/dumps/{uuid}', {method="POST", body = "a" * (1024*16 - 154) })

Really loving working with redbean and fullmoon so far though, great work!

elitepleb avatar Aug 26 '22 18:08 elitepleb

@elitepleb, thank you for the report and the test case. I'd say it's intended use, so would expect it to work. I'll have a chance to check it later today to confirm. Just to be clear, what OS are you running this on? Does --strace option show anything interesting before the error? Thanks!

pkulchenko avatar Aug 26 '22 19:08 pkulchenko

Linux and Windows, latest available redbean-2.0.17.com build. Behavior repeats with and without assimilation.

--strace dump does not seem to show anything interesting

SYS 1488853    190'089'242'298 openat(AT_FDCWD, "/home/pleb/.redbean_history", 0, 0) → 4 EBADMSG/74/Not a data message
SYS 1488853    190'089'278'867 fstat(4, [{.st_size=121, .st_blocks=4'096/512, .st_mode=0100600, .st_uid=1000, .st_gid=1000, .st_ino=9971906}]) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'089'363'426 mmap(0, 121, PROT_READ, MAP_SHARED, 4, 0) → 0x100080110000 EBADMSG/74/Not a data message (4'063'232 bytes total)
SYS 1488853    190'089'444'030 munmap(0x100080110000, 121) → 0 EBADMSG/74/Not a data message (3'997'696 bytes total)
SYS 1488853    190'089'472'794 close(4) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'089'492'273 umask(022) → 0
SYS 1488853    190'089'660'319 openat(AT_FDCWD, "/home/pleb/.redbean_history", O_WRONLY|O_CREAT|O_TRUNC, 0666) → 4 EBADMSG/74/Not a data message
SYS 1488853    190'089'695'697 umask(0177) → 04
SYS 1488853    190'089'726'646 fchmodat(AT_FDCWD, "/home/pleb/.redbean_history", 0600, 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'089'812'797 write(4, u"Fetch(‘https://httpdump.app/dumps/2859c2"..., 121) → 121 EBADMSG/74/Not a data message
SYS 1488853    190'089'985'870 close(4) → 0 EBADMSG/74/Not a data message

SYS 1488853    190'090'043'087 write(1, u"◙", 1) → 1 EBADMSG/74/Not a data message
SYS 1488853    190'090'165'567 sigaction(SIGINT, {.sa_handler=&laction, .sa_flags=0x80000000, .sa_mask={}}, [{.sa_handler=0, .sa_flags=0x4000000, .sa_mask={}}]) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'090'626'210 mmap(0, 65'536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) → 0x100080110000 EBADMSG/74/Not a data message (4'063'232 bytes total)
SYS 1488853    190'090'742'708 socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP) → 4 EBADMSG/74/Not a data message
SYS 1488853    190'090'838'674 sendto(4, u"╜╓☺  ☺      ◘httpdump♥app  ☺ ☺", 30, 0, 0x62f248, 16) → 30 EBADMSG/74/Not a data message
SYS 1488853    190'104'649'266 read(4, [u"╜╓üÇ ☺ ☺    ◘httpdump♥app  ☺ ☺└♀ ☺ ☺  ◘‘"...], 512) → 46 EBADMSG/74/Not a data message
SYS 1488853    190'104'698'449 close(4) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'104'746'474 socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) → 4 EBADMSG/74/Not a data message
SYS 1488853    190'104'769'123 setsockopt(4, SOL_TCP, TCP_FASTOPEN_CONNECT, u"☺   ", 4) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'104'784'016 setsockopt(4, SOL_TCP, TCP_QUICKACK, u"☺   ", 4) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'104'798'214 setsockopt(4, SOL_SOCKET, SO_RCVTIMEO, u"<               ", 16) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'104'811'767 setsockopt(4, SOL_SOCKET, SO_SNDTIMEO, u"<               ", 16) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'137'974'109 connect(4, 142.93.106.246:443) -> 0 EBADMSG/74/Not a data message
SYS 1488853    190'138'065'127 gettimeofday([{1661543269, 898635}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'138'169'667 writev(4, {{u"", 0}, {u"▬♥☺ ╟☺  ├♥♥c○#e4╜┼‘ü╜v←x╟↕π╩£▌L@I»â*≥7┌Z"..., 204}}, 2) → 204 EBADMSG/74/Not a data message
SYS 1488853    190'172'567'272 readv(4, [{{u"▬♥♥ T", 5}, {u"☻  P♥♥Ω▲î¥ÉªaX╓♂7»q╝°>↨►c-ª▓╖qDOWNGRD☺ └"..., 4'000}}], 2) → 4'005 EBADMSG/74/Not a data message
SYS 1488853    190'172'642'368 gettimeofday([{1661543269, 938411}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'172'786'958 gettimeofday([{1661543269, 938578}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'172'802'028 gettimeofday([{1661543269, 938596}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'173'213'055 gettimeofday([{1661543269, 939068}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'173'229'298 gettimeofday([{1661543269, 939087}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'173'250'496 gettimeofday([{1661543269, 939111}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'173'269'238 gettimeofday([{1661543269, 939133}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'174'704'686 gettimeofday([{1661543269, 940782}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'174'729'743 gettimeofday([{1661543269, 940812}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'174'768'392 gettimeofday([{1661543269, 940856}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'174'787'091 gettimeofday([{1661543269, 940878}], 0) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'174'820'774 readv(4, [{{u"0☼âEáW║@w2∙¼‼{IxΣ╟K^)_¶┐Σä⁇«╞zá╒]d⌂>⌐<◄┴"..., 99}, {u"▬♥♥ ♦♫   "..., 4'000}}], 2) → 108 EBADMSG/74/Not a data message
SYS 1488853    190'183'938'195 writev(4, {{u"", 0}, {u"▬♥♥ %►  ! ╞ßD¥Ñá┘&-%gj╣◙╛╟C╕fvüScB±MAzéó"..., 42}}, 2) → 42 EBADMSG/74/Not a data message
SYS 1488853    190'184'316'503 writev(4, {{u"", 0}, {u"¶♥♥ ☺☺", 6}}, 2) → 6 EBADMSG/74/Not a data message
SYS 1488853    190'184'437'139 writev(4, {{u"", 0}, {u"▬♥♥ (        ù─═u}æG€{τà═τ┌█mH;â♂4│OÆûÜ%"..., 45}}, 2) → 45 EBADMSG/74/Not a data message
SYS 1488853    190'251'682'589 readv(4, [{{u"▬♥♥ ┌", 5}, {u"♦  ╓  ☺, ╨s≈╪ƒ↓Γö¶^Yäc▲!m ]↨î¢╕Çs)±ñ╬r ╓"..., 4'000}}], 2) → 274 EBADMSG/74/Not a data message
SYS 1488853    190'252'254'971 writev(4, {{u"", 0}, {u"↨♥♥@↑       ☺╗U%(≥÷◘∟▌Nφ┴¢ìr:▓↓gÜJf♥▼P@`"..., 16'413}}, 2) → 16'413 EBADMSG/74/Not a data message
SYS 1488853    190'252'385'890 close(4) → 0 EBADMSG/74/Not a data message
SYS 1488853    190'252'437'477 sigaction(SIGINT, {.sa_handler=0, .sa_flags=0x4000000, .sa_mask={}}, [NULL]) → 0 EBADMSG/74/Not a data message
nil     "tls write failed (UNKNOWN ERROR CODE (4000) -0xffffc000)"

elitepleb avatar Aug 26 '22 19:08 elitepleb

Is this related to STATIC_STACK_SIZE?

ahgamut avatar Aug 26 '22 23:08 ahgamut