meilisearch / heed

A fully typed LMDB wrapper with minimum overhead 🐦
https://docs.rs/heed
MIT License
569 stars 52 forks source link

Opening an `Env` must be `unsafe` #207

Closed Kerollmops closed 6 months ago

Kerollmops commented 1 year ago

According to some comments, we should mark the opening of the LMDB environment as unsafe. I found out that most people agree on that, and we could list the issues that opening an environment with memory-mapping could bring by using the official documentation.

zoo868e commented 1 year ago

Hi @Kerollmops, I would like to try this. However, I can't compile the project. Here is the output of cargo check

   Compiling lmdb-master-sys v0.1.0 (/home/matt_jan/heed/lmdb-master-sys)
The following warnings were emitted during compilation:

warning: In file included from /usr/local/include/linux/stat.h:6,
warning:                  from /usr/include/x86_64-linux-gnu/bits/statx.h:31,
warning:                  from /usr/include/x86_64-linux-gnu/sys/stat.h:465,
warning:                  from /home/matt_jan/heed/lmdb-master-sys/lmdb/libraries/liblmdb/mdb.c:102:
warning: /usr/local/include/asm/stat.h:8:10: fatal error: uapi/asm/stat.h: No such file or directory
warning:     8 | #include <uapi/asm/stat.h>
warning:       |          ^~~~~~~~~~~~~~~~~
warning: compilation terminated.

error: failed to run custom build command for `lmdb-master-sys v0.1.0 (/home/matt_jan/heed/lmdb-master-sys)`

Caused by:
  process didn't exit successfully: `/home/matt_jan/heed/target/debug/build/lmdb-master-sys-aca218c1dc508df9/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CC_x86_64-unknown-linux-gnu
  CC_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_unknown_linux_gnu
  CC_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-linux-gnu
  CFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_linux_gnu
  CFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-Wno-unused-parameter" "-Wbad-function-cast" "-Wuninitialized" "-o" "/home/matt_jan/heed/target/debug/build/lmdb-master-sys-989ea626efd4ffd9/out/e361845b6c5e9f4f-mdb.o" "-c" "/home/matt_jan/heed/lmdb-master-sys/lmdb/libraries/liblmdb/mdb.c"
  cargo:warning=In file included from /usr/local/include/linux/stat.h:6,

  cargo:warning=                 from /usr/include/x86_64-linux-gnu/bits/statx.h:31,

  cargo:warning=                 from /usr/include/x86_64-linux-gnu/sys/stat.h:465,

  cargo:warning=                 from /home/matt_jan/heed/lmdb-master-sys/lmdb/libraries/liblmdb/mdb.c:102:

  cargo:warning=/usr/local/include/asm/stat.h:8:10: fatal error: uapi/asm/stat.h: No such file or directory

  cargo:warning=    8 | #include <uapi/asm/stat.h>

  cargo:warning=      |          ^~~~~~~~~~~~~~~~~

  cargo:warning=compilation terminated.

  exit status: 1

  --- stderr

  error occurred: Command "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-Wno-unused-parameter" "-Wbad-function-cast" "-Wuninitialized" "-o" "/home/matt_jan/heed/target/debug/build/lmdb-master-sys-989ea626efd4ffd9/out/e361845b6c5e9f4f-mdb.o" "-c" "/home/matt_jan/heed/lmdb-master-sys/lmdb/libraries/liblmdb/mdb.c" with args "cc" did not execute successfully (status code exit status: 1).

There is no directory uapi/asm/stat.h in my laptop, are there any suggestion?

Kerollmops commented 1 year ago

Thank you @zoo868e,

I really don't know. Have you read the README in details and pulled the git submodules?

If so, you are basically trying to compile LMDB. So, you should be looking at discussion mentioning the issue you have.

zoo868e commented 1 year ago

Yes, I had clone the repo recursively and also git submodule update --recursive. Seems is the issue of the LMDB, I'm trying to figure out the solution.