diasurgical / devilutionX

Diablo build for modern operating systems
Other
7.99k stars 781 forks source link

[Issue Report]: nxdk does not implement `strtod()` #6967

Open StephenCWills opened 7 months ago

StephenCWills commented 7 months ago

Operating System

Other (please specify)

DevilutionX version

Custom build (please specify commit ID)

Describe

Platform: OG Xbox Commit ID: 55a5337 (no release versions are affected)

The build for OG Xbox fails at startup with the following message.

Assertion failed: '0' in function 'strtod', file '/opt/nxdk/lib/xboxrt/libc_extensions/stdlibext.c', line 91

To Reproduce

  1. Run the OG Xbox build in xemu
  2. You will see the error message almost immediately

Expected Behavior

No response

Additional context

I added some trace logging and found that the assertion is raised here in LuaInitialize().

https://github.com/diasurgical/devilutionX/blob/55a5337834a9c26861e3f6db790c8949adef8e20/Source/lua/lua.cpp#L218-L229

I didn't dig any deeper than this since I'm pretty sure it's called by Lua internals. There's likely no reasonable way for us to work around the missing function.


Someone already posted an issue for this a few years back: https://github.com/XboxDev/nxdk/issues/508. We will probably need to submit a PR to have any hope of getting this implemented for 1.6.0. Otherwise, we'll just have to disable Lua on OG Xbox.

Here is the link to their stub for the function. https://github.com/XboxDev/nxdk/blob/ed21e83da43b8b8da14a9a78cf2528d9b5df86a7/lib/xboxrt/libc_extensions/stdlib_ext_.c#L89-L93


Also, this isn't really necessary, but I did take a screenshot of the error earlier so I may as well share it.

image

glebm commented 7 months ago

nxdk uses PDClib, which doesn't have strtod but they have a draft implementation:

https://github.com/DevSolar/pdclib/blob/7d471427fa986a9f4cafb069af17821ee7868141/functions/_PDCLIB/_PDCLIB_strtod_main.c#L16-L20

It'd probably be best to submit a PR to PDClib directly.

AJenbo commented 7 months ago

https://github.com/XboxDev/nxdk-pdclib/pull/57#issuecomment-1948043421

glebm commented 7 months ago

I found high quality public domain implementations of float<->string conversions in sqlite https://github.com/DevSolar/pdclib/issues/5#issuecomment-1950136787

glebm commented 6 months ago

Sent a PR to PDClib with a partial strtod implementation based on the one from SQLite https://github.com/DevSolar/pdclib/pull/22