Author Topic: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)  (Read 7084 times)

Offline Grandfather

  • Acquaintance
  • *
  • Posts: 3
    • View Profile
[RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« on: July 12, 2008, 06:07:00 pm »
This runtime error was generated trying to BUY a SANDWICH from GLORIA in the campus area:

Code: [Select]
2008.07.12-17.06,35
*Division by zero
Object: /secure/sefun/sefun at /secure/sefun/economy.c:69

'<fake>' at /secure/save/players/j/jaecen (/<driver>) at line 0
'cmdAll' at /secure/save/players/j/jaecen (/lib/command.c) at line 141
'do_buy_str_from_liv' at /verbs/items/buy at line 36
'eventSell' at /domains/campus/npc/gloria#217 (/lib/std/barkeep.c) at line 133
'query_value' at /secure/sefun/sefun at /secure/sefun/economy.c:69
---
2008.07.12-17.07,17
*Division by zero
Object: /secure/sefun/sefun at /secure/sefun/economy.c:69

'<fake>' at /secure/save/players/j/jaecen (/<driver>) at line 0
'cmdAll' at /secure/save/players/j/jaecen (/lib/command.c) at line 141
'do_buy_str_from_liv' at /verbs/items/buy at line 36
'eventSell' at /domains/campus/npc/gloria#217 (/lib/std/barkeep.c) at line 133
'query_value' at /secure/sefun/sefun at /secure/sefun/economy.c:69

This one was generated trying to
Code: [Select]
2008.07.12-18.49,56
*Division by 0.0
Object: /domains/town/npc/otik#1162 (/lib/std/vendor.c) at line 319

'appraise' at /domains/town/room/shop (/lib/shop.c) at line 43
'cmdAppraise' at /domains/town/npc/otik#1162 (/lib/std/vendor.c) at line 319
---
2008.07.12-18.50,02
*Division by 0.0
Object: /domains/town/npc/otik#1162 (/lib/std/vendor.c) at line 319

'appraise' at /domains/town/room/shop (/lib/shop.c) at line 43
'cmdAppraise' at /domains/town/npc/otik#1162 (/lib/std/vendor.c) at line 319
---
2008.07.12-18.55,26
*Division by 0.0
Object: /domains/town/npc/otik#1162 (/lib/std/vendor.c) at line 319

'appraise' at /domains/town/room/shop (/lib/shop.c) at line 43
'cmdAppraise' at /domains/town/npc/otik#1162 (/lib/std/vendor.c) at line 319

From the looks of it (being that I'm new to the lib, I'm not certain) there's a division by 0 not being caught somewhere.
« Last Edit: July 12, 2008, 06:10:28 pm by Grandfather »

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #1 on: July 12, 2008, 08:24:39 pm »
Looks like something's up with your economy data.

What are the contents of the economy save file?

It's /save/economy.o

-Crat

Offline Grandfather

  • Acquaintance
  • *
  • Posts: 3
    • View Profile
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #2 on: July 13, 2008, 08:59:00 am »
Code: [Select]
#/secure/daemon/economy.c
Currencies ([])
LastInflation 1215914073

Hmm, no currencies. That's likely the problem?

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #3 on: July 13, 2008, 09:11:59 am »
Yeah, that's it. I don't know why that happened but that's the
problem you're having.

Shut down the mud, copy the economy.o from the distribution over
that file, start back up, and you should be ok.

-Crat

Offline Raudhrskal

  • BFF
  • ***
  • Posts: 214
  • The MUD community needs YOUR help!
    • View Profile
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #4 on: July 13, 2008, 10:04:37 am »
It may be related to the old bug "cannot restore from economy.o" related to European locales putting comma in floating point numbers. You know, the one circumvented in bin/startmud. If economy hasn't been restored, the newly saved version will be empty.

A'propos - maybe we could ask Wodan to add setlocale(LC_NUMERIC <or LC_ALL> ,"C") somewhere near the beginning of the driver bootstrap process? Or, other option, find the place where floats are stringified and replace all ',' with '.' :D

Er, I've just read the glibc manual...
7.4 How Programs Set the Locale

A C program inherits its locale environment variables when it starts up. This happens automatically. However, these variables do not automatically control the locale used by the library functions, because ISO C says that all programs start by default in the standard `C' locale. To use the locales specified by the environment, you must call setlocale. Call it as follows:

setlocale (LC_ALL, "");

to select a locale based on the user choice of the appropriate environment variables.
Looks like fluff already calls setlocale where it shouldn't... or glibc again has inconsistent documentation...
I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #5 on: July 13, 2008, 10:19:17 am »
Search bots, mostly.

Sometimes a search site fires off multiple bots for this site. I don't really
understand it, but I'm glad that they're helping people know the site is here.

It's pretty prominent on seaches for "lpmuds"

-Crat

Offline Raudhrskal

  • BFF
  • ***
  • Posts: 214
  • The MUD community needs YOUR help!
    • View Profile
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #6 on: July 13, 2008, 10:53:28 am »
Yep.

fluffos-2.11-ds18/main.c:92: setlocale (LC_ALL, "");

Either comment it, or (just to be sure) change "" to "C", or (if you want to have rest localized) change LC_ALL to LC_ALL & (~LC_NUMERIC) or something.

And... the dreaded floating-point comma bug is gone... after all these years...

Gonna recompile and test, but there shouldn't be any weird side-effects...

Any driver wizard wanting to comment?
I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #7 on: July 13, 2008, 11:01:05 am »
Heh oops, sorry bout the earlier mis-post.

I'll try the driver thingy. Sounds sweet.

-Crat

Offline Raudhrskal

  • BFF
  • ***
  • Posts: 214
  • The MUD community needs YOUR help!
    • View Profile
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #8 on: July 13, 2008, 11:13:52 am »
I hope so.

It'd be somewhat ironic - I was the author of this email sent to you over two years ago (3rd of April to be precise - *just* love Gmail) with the old fix using exports in startmud. ;)
And, because it worked for you, me and most of other people, I haven't bothered to look deeper into it up till today... ;D
I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...

Offline Raudhrskal

  • BFF
  • ***
  • Posts: 214
  • The MUD community needs YOUR help!
    • View Profile
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #9 on: July 15, 2008, 08:03:21 am »
[Double-post to bump up]

Updated today to your a6 with fluff 2.12 . Still no side effects,
and economy.o saves correctly - no matter what bizarre locale I set ;) .

(Of course testing with the old workaround in startmud _disabled_ :D)
I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #10 on: July 15, 2008, 08:59:22 am »
Quote
Still no side effects, and economy.o saves correctly - no matter what bizarre locale I set

Awesome. I'm very glad it's working out.

Regarding the blank economy.o, though, just in case the locale isn't the
problem, 2.9a6 ECONOMY_D now checks before it does a save_object(),
and won't save a "null economy".

I can't think of any normal situation where that would happen, but apparently
it does, since more than one person ran into it, so now it's a handled exception.

Thanks for the tips, folks. Please keep those reports coming. I can't improve
the lib distro if I don't get reports!

-Crat

Offline Raudhrskal

  • BFF
  • ***
  • Posts: 214
  • The MUD community needs YOUR help!
    • View Profile
Re: [RUNTIME] [DS 2.9a5] Appraise and buy (situational)
« Reply #11 on: July 15, 2008, 02:59:49 pm »
Yeah, I saw that. But it won't help in any way, sorry ;(

To reclarify, the sequence of events leading to bug was:

1. You boot the mud first time with locale specifying "i want commas in floats". This includes many European locales. For sure Polish and Hungarian ;)
2. ECONOMY_D restores the stock .o file, everything is ok...
3. (later) ECONOMY_D wants to save his mapping.
But it saves it as
Code: [Select]
#/secure/daemon/economy.c
Currencies (["dollars":(["rate":100,000000,"weight":0,001000,"inflation":0,000000,]),"silver":(["rate":100,"weight":0,800000,"inflation":0,000000,]),"electrum":(["rate":500,"weight":0,004000,"inflation":0,000000,])<etc...>,])
LastInflation 1150654990
Note that floats has been printf()ed with commas, so the resulting mapping is invalid.
4. Daemon uses data from memory, and everything work right.
5. Reboot (or update(ECONOMY_D) ) occurs.
6. Cannot restore from economy.o - invalid file format
7. The mapping inside daemon is empty, because it couldn't be restored from file.

Yes, now your fix will kick in and forbid saving the empty mapping. But the file has been damaged by the PREVIOUS run.

Good news: ISO C standard requires that in default "C" locale floats MUST be printf()ed with dot as separator.
So, now we're secured.

PS. According to ChangeLog.beta, locale support has been added in MudOS 22.1b28, "[based on patches from Naebator@Remedy]". Question: WHY? We don't have one translated message in the whole driver.
Hmm... string categorization/sorting routines? OK, if you want to make a mud in foreign language, and use libc functions on 'em...
OTOH, probably NO ONE of today's mudadmins will even think of setting locales on their server - especially if it's a paid hosting...
If you want to leave it as an option (so e.g. sorting wili put national characters in their place in local alphabet, not at the end after all ASCII), make that line in main.c:
Code: [Select]
setlocale(LC_ALL & (~LC_NUMERIC), "");
This will localize everything EXCEPT numbers. Note - that char in front of LC is a tilde - on my screen it is very dash-ish, dunno how it looks for you.

Now, let's go and make that mudlib even more a**-kicking...

'Skal
I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...