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

Firebird crashes if a plugin factory returns nullptr and no error in status #8101

Closed
aafemt opened this issue May 4, 2024 · 11 comments
Closed

Comments

@aafemt
Copy link
Contributor

aafemt commented May 4, 2024

If a trace plugin's factory returns nullptr and no error in status - Firebird crashes trying to reference this pointer. Returned value should be checked for nullptr in any case.

@hvlad
Copy link
Member

hvlad commented May 4, 2024

What is Firebird version and call stack of crash ?

@aafemt
Copy link
Contributor Author

aafemt commented May 4, 2024

Firebird 4.0.4.2981

No stack trace but I guess the crash occur on TraceManager.cpp:148 line info.factory->addRef(); after previous line assigned nullptr returned from traceItr.plugin() to info.factory because GetPlugins::getPlugin() check status for error but doesn't check returned value.

And this code is the same in all versions.

@hvlad
Copy link
Member

hvlad commented May 4, 2024

It is still not clear what do you speak about - the bug in TraceManager ? in PluginManager ? in some implementation of custom (trace) plugin ?
It is important to know to fix a root issue, not particular case (what case?)

@aafemt
Copy link
Contributor Author

aafemt commented May 4, 2024

IMHO it is a bug in TraceManager. It must not trust plugin's sanity and check returned values.

@hvlad
Copy link
Member

hvlad commented May 4, 2024

Did you check another callers of GetPlugins::plugin() ?

@aafemt
Copy link
Contributor Author

aafemt commented May 4, 2024

I'm sorry, my guess was wrong. The returned value is checked there by hasData() call.

But in ConfiguredPlugin::factory() value returned by createPlugin() isn't checked before calling setOwner() unless I missed something again.

aafemt added a commit to aafemt/firebird that referenced this issue May 5, 2024
@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented May 6, 2024 via email

@hvlad
Copy link
Member

hvlad commented May 6, 2024

I'm sorry, my guess was wrong.

Don't you think that issue title should be changed ?

@aafemt aafemt changed the title Firebird crashes if createPlugin() return nullptr and no error for a trace plugin Firebird crashes if a plugin factory returns nullptr and no error in status May 6, 2024
@aafemt
Copy link
Contributor Author

aafemt commented May 6, 2024

And if plugin factory returned no error it must return valid interface pointer. In this case plugin should be fixed. It can cause segfault in 100500 other ways, what a sense to fux one case?

100500 other places already protected by hasData() call as I said above. nullptr is a valid pointer. At least specs doesn't say otherwise. Factory may have a reason to refuse return plugin object not related to any error and just want the engine to proceed to the next plugin in list.

@AlexPeshkoff
Copy link
Member

For me valid pointer is one that may be de-referenced successfully. But I do not want to waste time with this discussion any more - in this place additional check does not cause something bad, add it please.

@aafemt
Copy link
Contributor Author

aafemt commented May 6, 2024

in this place additional check does not cause something bad, add it please.

Do you mean an additional check besides one that is added in the PR?

hvlad added a commit that referenced this issue May 14, 2024
Fix for #8101 : Firebird crashes if a plugin factory returns nullptr and no error in status
hvlad pushed a commit that referenced this issue May 15, 2024
@hvlad hvlad closed this as completed May 20, 2024
hvlad pushed a commit that referenced this issue May 29, 2024
hvlad added a commit that referenced this issue May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants