DNS-OARC / dnsjit

Engine for capturing, parsing and replaying DNS
GNU General Public License v3.0
57 stars 12 forks source link

floating point numbers not supported with dnsjit.core.thread.push/pop #233

Closed nicki-krizek closed 7 months ago

nicki-krizek commented 7 months ago

From thead.push() description in manual, I would expect that even floating point numbers would be supported (since lua has only one number type):

   Thread:push(...)
         Push string(s), number(s) or sharable object(s) onto the thread stack so they
         can be retrieved inside the thread using pop().  The sharable object(s) needs
         to  be  kept  alive as long as the thread is running, strings and numbers are
         copied.

But the numbers are cast to int64 when they're pushed, silently trimming any decimal places. It'd be nice to have a mention of this in the manual.

jelu commented 7 months ago

@tkrizek can you test now with latest develop branch?

nicki-krizek commented 7 months ago

I'm afraid it doesn't work for me. Here's the reproducer:

#!/usr/bin/env dnsjit

local thread = require("dnsjit.core.thread")

local function thread_main(thr)
    print(thr:pop())
    print(thr:pop())
end

local t = thread.new()
t:start(thread_main)
t:push(1)
t:push(1.21)

t:stop()

With 1.3.0, I get:

1
1

And when testing with 07b35b7, I get this error:

core/thread.luah:61: declaration specifier expected near 'lua_Number' at line 31
jelu commented 7 months ago

Fixed!

$ src/dnsjit t.lua 
1
1.21