Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
StephenCWills opened this issue Feb 16, 2024 · 4 comments
Open

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

StephenCWills opened this issue Feb 16, 2024 · 4 comments
Milestone

Comments

@StephenCWills
Copy link
Member

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/stdlib_ext_.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().

CurrentLuaState->commonPackages = lua.create_table_with(
#ifdef _DEBUG
"devilutionx.dev", LuaDevModule(lua),
#endif
"devilutionx.version", PROJECT_VERSION,
"devilutionx.log", LuaLogModule(lua),
"devilutionx.audio", LuaAudioModule(lua),
"devilutionx.render", LuaRenderModule(lua),
"devilutionx.message", [](std::string_view text) { EventPlrMsg(text, UiFlags::ColorRed); },
// These packages are loaded without a sandbox:
"devilutionx.events", CurrentLuaState->events,
"inspect", RunScript(/*env=*/std::nullopt, "inspect", /*optional=*/false));

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: XboxDev/nxdk#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

@AJenbo AJenbo added this to the 1.6.0 milestone Feb 16, 2024
@glebm
Copy link
Collaborator

glebm commented Feb 16, 2024

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
Copy link
Member

AJenbo commented Feb 16, 2024

@glebm
Copy link
Collaborator

glebm commented Feb 17, 2024

I found high quality public domain implementations of float<->string conversions in sqlite DevSolar/pdclib#5 (comment)

@glebm
Copy link
Collaborator

glebm commented Feb 25, 2024

Sent a PR to PDClib with a partial strtod implementation based on the one from SQLite DevSolar/pdclib#22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants