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

Opening a database from the home directory causes a segmentation fault #3104

Closed
mxwli opened this issue Mar 21, 2024 · 2 comments · Fixed by #3108
Closed

Opening a database from the home directory causes a segmentation fault #3104

mxwli opened this issue Mar 21, 2024 · 2 comments · Fixed by #3108
Assignees
Labels
bug Something isn't working

Comments

@mxwli
Copy link
Collaborator

mxwli commented Mar 21, 2024

How to reproduce:

import kuzu
db = kuzu.Database("~/tmpdatabase")

This produces a segmentation fault for me. I'm running on the master branch.

@mxwli mxwli added the bug Something isn't working label Mar 21, 2024
@prrao87
Copy link
Member

prrao87 commented Mar 21, 2024

I can confirm that the segfault occurs in the latest release (0.3.2) as well. The issue seems to be with parsing the ~ character in the path (if I specify the full home directory path, there's no issue).

@mxwli
Copy link
Collaborator Author

mxwli commented Mar 21, 2024

When testing this with the CLI, use ./kuzu_shell "~/tmpdatabase" instead of ./kuzu_shell ~/tmpdatabase to trigger the segmentation fault. I ran gdb. Here's the stack trace

#0  0x00005555557aa902 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data (this=0x0) at /usr/include/c++/12/bits/basic_string.h:234
#1  0x00005555557aa792 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (this=0x7fffffffc240, __str=<error reading variable: Cannot access memory at address 0x8>) at /usr/include/c++/12/bits/basic_string.h:544
#2  0x0000555555c1d3b8 in kuzu::main::HomeDirectorySetting::getSetting (context=0x0) at /data/maxwell/workspace/kuzu/kuzu/src/include/main/settings.h:78
#3  0x0000555555b9f87f in kuzu::main::ClientContext::getCurrentSetting (this=0x0, optionName="home_directory") at /data/maxwell/workspace/kuzu/kuzu/src/main/client_context.cpp:97
#4  0x0000555555d07b29 in kuzu::common::LocalFileSystem::openFile (this=0x555556df6f70, path="~/tmpdatabase/.lock", flags=66, context=0x0, lock_type=kuzu::common::FileLockType::WRITE_LOCK) at /data/maxwell/workspace/kuzu/kuzu/src/common/file_system/local_file_system.cpp:47
#5  0x0000555555859828 in kuzu::common::VirtualFileSystem::openFile (this=0x555556df8f50, path="~/tmpdatabase/.lock", flags=66, context=0x0, lockType=kuzu::common::FileLockType::WRITE_LOCK) at /data/maxwell/workspace/kuzu/kuzu/src/common/file_system/virtual_file_system.cpp:20
#6  0x0000555555bb2c1a in kuzu::main::Database::openLockFile (this=0x555556df6390) at /data/maxwell/workspace/kuzu/kuzu/src/main/database.cpp:147
#7  0x0000555555bb2d7b in kuzu::main::Database::initDBDirAndCoreFilesIfNecessary (this=0x555556df6390) at /data/maxwell/workspace/kuzu/kuzu/src/main/database.cpp:157
#8  0x0000555555bb2189 in kuzu::main::Database::Database (this=0x555556df6390, databasePath="~/tmpdatabase", systemConfig=...) at /data/maxwell/workspace/kuzu/kuzu/src/main/database.cpp:83
#9  0x00005555557ae9e6 in std::make_unique<kuzu::main::Database, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, kuzu::main::SystemConfig const&> () at /usr/include/c++/12/bits/unique_ptr.h:1065
#10 0x00005555557a67b2 in kuzu::main::EmbeddedShell::EmbeddedShell (this=0x7fffffffc910, databasePath="~/tmpdatabase", systemConfig=..., pathToHistory=0x7fffffffc990 "history.txt") at /data/maxwell/workspace/kuzu/kuzu/tools/shell/embedded_shell.cpp:300
#11 0x00005555557f2aad in main (argc=2, argv=0x7fffffffdf28) at /data/maxwell/workspace/kuzu/kuzu/tools/shell/shell_runner.cpp:76

The problem seems to be caused by a nullptr dereference of ClientContext, which was explicitly passed as a nullptr in frame 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants