cginternals / cginternals/gloperate

DuktapeScriptBackend crashes when trying to serialize GLM properties

Open
#180 0 comments 0 reactions 0 assignees View on GitHub
Core pending requires decision
Dominant language
C++
Stars
43
Forks
24
PR merge metrics
No merged PRs in 30d

Description

I'm not sure, whether this is supposed to be an issue of gloperate or cppexpose.

To reproduce: Run gloperate-qt-example and enter `gloperate.canvas0.pipeline.virtualViewport` into script console. The `DuktapeScriptBackend` runs into an infinite recursion, eventually causing a stack overflow:
- During evaluation, `DuktapeObjectWrapper::getPropertyValue` is called on the pipeline object
- The function then retrieves the `virtualViewport` property from the object and converts it to a `Variant`. This variant internally stores a `glm::vec4`.
- Next, `DuktapeScriptBackend::pushToDukStack` is called to return the result to the script via the duktape stack
- Here is the problem: this function operates **only on built-in variant types**, it **does nothing for custom types**, which means the stack is unchanged
- This causes the infinite recursion, as trying to output the result (expected at the top of the stack) starts the whole sequence all over

I don't know much about Duktape, so I'm not entirely sure how the stack exactly looks like in each step, so please excuse any inaccuracies in my description ;).

One idea to solve this would be to push the variant's string representation to the duktape stack.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the reported call chain from `DuktapeObjectWrapper::getPropertyValue` to `DuktapeScriptBackend::pushToDukStack` while reproducing with `gloperate-qt-example` and `gloperate.canvas0.pipeline.virtualViewport`. Check how custom `Variant` types such as `glm::vec4` are handled and how the Duktape stack changes. Done means evaluating this property no longer recurses or overflows and returns a usable result to the script.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.