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

Null pointer dereference in X11 initialization error message #86436

Closed
ttencate opened this issue Dec 22, 2023 · 2 comments · Fixed by #86843
Closed

Null pointer dereference in X11 initialization error message #86436

ttencate opened this issue Dec 22, 2023 · 2 comments · Fixed by #86843

Comments

@ttencate
Copy link
Contributor

Tested versions

master (9d1cbab)

System information

n/a

Issue description

context_rd = nullptr;
r_error = ERR_CANT_CREATE;
ERR_FAIL_MSG(vformat("Could not initialize %s", context_rd->get_api_name()));

Steps to reproduce

Didn't actually try to trigger this, but my compiler warned about it.

Minimal reproduction project (MRP)

n/a

@timothyqiu
Copy link
Member

FYI: It won't crash in practice because all get_api_name() simply return a string literal.

@akien-mga
Copy link
Member

I noticed this too, as commented on the PR which introduced it:

@RandomShaper I'm running into this warning with GCC 12.3.0 on Linux when building with scons warnings=extra werror=yes tests=yes verbose=yes:

In file included from ./core/os/mutex.h:34, 
                 from ./core/os/thread_safe.h:34, 
                 from ./core/object/message_queue.h:35, 
                 from ./core/object/object.h:35, 
                 from ./core/variant/binder_common.h:35, 
                 from ./core/object/method_bind.h:34, 
                 from ./core/object/class_db.h:34, 
                 from ./core/object/ref_counted.h:34, 
                 from ./core/io/resource_uid.h:34, 
                 from ./core/io/resource.h:34, 
                 from ./core/input/input_event.h:35, 
                 from ./core/input/input.h:34, 
                 from platform/linuxbsd/joypad_linux.h:36, 
                 from platform/linuxbsd/x11/display_server_x11.h:36, 
                 from platform/linuxbsd/x11/display_server_x11.cpp:31: 
platform/linuxbsd/x11/display_server_x11.cpp: In constructor 'DisplayServerX11::DisplayServerX11(const String&, DisplayServer::WindowMode, DisplayServer::VSyncMode, uint32_t, const Vector2i*, const Vector2i&, in
t, Error&)': 
platform/linuxbsd/x11/display_server_x11.cpp:6034:45: error: 'this' pointer is null [-Werror=nonnull] 
 6034 |                         ERR_FAIL_MSG(vformat("Could not initialize %s", context_rd->get_api_name())); 
      |                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
./core/error/error_macros.h:595:95: note: in definition of macro 'ERR_FAIL_MSG' 
  595 |                 _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/function failed.", m_msg); \ 
      |                                                                                               ^~~~~

Weirdly enough, I don't reproduce it on my main laptop with the same distro and GCC version, with dev_build=yes dev_mode=yes scu_build=all.

Haven't looked into what the warning means yet.

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

Successfully merging a pull request may close this issue.

5 participants