Page 1 of 1

crash - String too long for serializeString

Posted: Mon Feb 22, 2021 05:09
by loosewheel
Game was hosted over LAN.

Crash occurred when the item was dropped (Q key).

When dropped in host machine:

Code: Select all

2021-02-22 13:48:44: ACTION[Server]: loosewheel uses lwcomputers:book, pointing at [nothing]
2021-02-22 13:48:50: ERROR[Server]: An unhandled exception occurred: String too long for serializeString
2021-02-22 13:48:50: ERROR[Server]: In thread 7f11597d7700:
2021-02-22 13:48:50: ERROR[Server]: /build/minetest-2HALFv/minetest-5.3.0/src/server.cpp:7d: virtual void* ServerThread::run(): A fatal error occurred: String too long for serializeString
When dropped in client machine, which crashes the host:

Code: Select all

2021-02-22 13:38:31: ACTION[Server]: mary uses lwcomputers:book, pointing at [nothing]
2021-02-22 13:38:31: WARNING[ConnectionSend]: con(18/1) Packet quota used up for peer_id=3, was 512 pkts
2021-02-22 13:38:32: WARNING[ConnectionSend]: con(18/1) Packet quota used up for peer_id=3, was 512 pkts
2021-02-22 13:38:32: WARNING[ConnectionSend]: con(18/1) Packet quota used up for peer_id=3, was 512 pkts
2021-02-22 13:38:34: WARNING[ConnectionSend]: con(18/1) Packet quota used up for peer_id=3, was 512 pkts
2021-02-22 13:38:39: ERROR[Server]: An unhandled exception occurred: String too long for serializeString
2021-02-22 13:38:39: ERROR[Server]: In thread 7fc4773ee700:
2021-02-22 13:38:39: ERROR[Server]: /build/minetest-2HALFv/minetest-5.3.0/src/server.cpp:7d: virtual void* ServerThread::run(): A fatal error occurred: String too long for serializeString
The item contains a lengthy string in its meta data.

Is there a work around/fix/setting for this, or is this a hard limit? What is the limit (how big is 512 pkts)?

Re: crash - String too long for serializeString

Posted: Mon Feb 22, 2021 19:42
by AiTechEye
i think its a hard limit, about 65000 characters, i also got this trouble, my workaround was to replace patterns to make the string shorter, eg if the string contains lots of ".png" you could repalce it with "!" then reverse when the string is used.

Re: crash - String too long for serializeString

Posted: Mon Feb 22, 2021 19:59
by Krock
https://github.com/minetest/minetest/issues/10981

Please run your game in "gdb" (Linux) or "windbg" (Windows) and reproduce the crash. Alternatively upload a world to properly reproduce it.

PS: You can ignore the "Packet quota used up" messages as long no players disconnect at random.

Re: crash - String too long for serializeString

Posted: Tue Feb 23, 2021 03:48
by loosewheel
@AiTechEye, I byte encoded the book data instead of using a serialised table. I can get a max of 5 pages. I seem to be able to put about 12kb in the metadata before this error occurs. The items that have disk space are way to big to reduce. I store the disk data in a file from the on_drop handler, and overrode the minetest.registered_entities["__builtin:item"].on_punch handler to put it back in the item when the item is picked up. This seems to work, but I think I’ll simplify the mechanism to use it with other items too.

Re: crash - String too long for serializeString

Posted: Tue Feb 23, 2021 04:00
by loosewheel
@Krock here is the output from gdb:
+ gdb output
I think the offender is here, file server.c, line 93. Line 7d (125) is the END_DEBUG_EXCEPTION_HANDLER macro.
+ code
It appears that when an item is dropped the item is converted to a string and sent to the server. When the string is larger than a certain size this causes the exception. The minetest.registered_entities["__builtin:item"].on_punch deals with the item as a string, including its metadata.

Re: crash - String too long for serializeString

Posted: Tue Feb 23, 2021 10:11
by hex
Never mind that a client has no business sending meta in the first place, but does the server just blindly believe whatever the client stuffs in there? How does this work?

Re: crash - String too long for serializeString

Posted: Tue Feb 23, 2021 14:13
by sfan5
This isn't the client sending meta, it's the server encountering an error upon trying to send more than 64k characters from somewhere in the in-game environment. Mods should take care not to store huge amounts of data inside item metadata.