emscripten-core / emscripten-core/emscripten
dynamic_cast returns null in MAIN_MODULE when created in SIDE_MODULE
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
dynamic_cast returns null in MAIN_MODULE when created in SIDE_MODULE. Simplified project is attached.
attached simplified cmake project.
[emscripten_dynamic_cast_test.zip](https://github.com/user-attachments/files/16626204/emscripten_dynamic_cast_test.zip)
Note that if the plugin.so is give as compilation input to main application it works. but in that situation it is not a plugin anymore.
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.61 (67fa4c16496b157a7fc3377afd69ee0445e8a6e3)
clang version 19.0.0git (https:/github.com/llvm/llvm-project 7cfffe74eeb68fbb3fb9706ac7071f8caeeb6520)
Target: wasm32-unknown-emscripten
Thread model: posix
common.h
```
#pragma once
class BasePluginData
{
public:
BasePluginData(int value, int size);
virtual ~BasePluginData() = default;
int m_value;
int m_size;
};
class DerivedPluginData:public BasePluginData
{
public:
DerivedPluginData(int value, int size, int derivedValue);
int m_derivedValue;
};
```
plugin.cpp
```
#include
#include "common.h"
using namespace std;
BasePluginData::BasePluginData(int value, int size):m_value(value),m_size(size)
{
}
DerivedPluginData::DerivedPluginData(int value, int size, int derivedValue):BasePluginData(value,size),m_derivedValue(derivedValue)
{
}
extern "C" {
BasePluginData* pluginCallBase()
{
cout<<"Executing pluginCallBase..."<
#include
#include // std::this_thread::sleep_for
#include // std::chrono::seconds
#include
#include
#include
#include "common.h"
using namespace std;
void callPlugin(const std::string& pluginName,const std::string& callName)
{
cout<<"Loading lib:"<m_value<<" "<m_size<(data);
if(derivedData)
{
cout<<"It is derived data with derivedValue:"<m_derivedValue< This line should be different and show value unique to derived as well
```
Contributor guide
Assessment
This issue has not been assessed yet.