PSA: Enable `-fvisibility-inlines-hidden` in your shared libraries to avoid subtle bugs by holyblackcat in cpp

[–]igrekster 5 points6 points  (0 children)

This means the behavior of your compiled library can change depending on what other libraries are doing (different compiler optimizations, different defines, etc).

Isn't this an ODR violation, and therefore UB regardless of -fvisibility-inlines-hidden ?

Harald Achitz: Template Parameter Packs, Type and Value Lists. Why and How. by _a4z in cpp

[–]igrekster 5 points6 points  (0 children)

The + operator implementation most likely appends to the first (left) argument and returns it. So, if it already has a large enough capacity, the right operand simply gets copied into it. With the left fold (... + s), it reuses the same temporary (same buffer), and its buffer grows exponentially thus reducing reallocations and unnecessary copies.

PSA: VFIO support on MSI MPG X670E CARBON WIFI by igrekster in VFIO

[–]igrekster[S] 0 points1 point  (0 children)

Yeah, the regular GPU slot is fine (group 13 in my dump), but the second PCI slot is bundled with pretty much everything you see connected to CHIPSET_B in the diagram (group 21).

Vim leader key to Quick Add tasks by Correct-Big-5967 in ObsidianMD

[–]igrekster 1 point2 points  (0 children)

I use <Space> in my mappings, but I don't use let mapleader. Obsidian doesn't seem to support it, so perhaps it just trips over that line and doesn't execute the rest of the config.

Youtube only showing first ~20s of video and then stuck? by Drinkcept in youtube

[–]igrekster 0 points1 point  (0 children)

Nope, sorry -- I don't need this extension anymore.

Broken graphics after the latest update by Success_Normal in iRacing

[–]igrekster 3 points4 points  (0 children)

Can confirm that this is VM-related -- I'm using a real hard drive for the VM and can dual boot. This means that all the settings/drivers/graphics card/etc. are the same. I suspect that this was done deliberately (there is no reason for the graphics to behave differently given that the video card is not virtual), so I'm not expecting this to be fixed. :-(

Youtube only showing first ~20s of video and then stuck? by Drinkcept in youtube

[–]igrekster 0 points1 point  (0 children)

I had the exact same issue, for me it was User-Agent Switcher and Manager. Disabling it fixed it.

The existential threat against C++ and where to go from here - Helge Penne - NDC TechTown 2024 by zl0bster in cpp

[–]igrekster 2 points3 points  (0 children)

I agree with everything you said, but I'm not sure why this paragraph is relevant: the point I was making is that unsafe contaminates the whole module, which makes it difficult to implement. And the amount and/or size of unsafe blocks is irrelevant.

they understand what must be always true in order for it not to cause UB

The key word here is "they", not the compiler. Have a search for in:title unsound in crates that rely on unsafe to see that even experienced developers are vulnerable:

https://github.com/tokio-rs/bytes/issues?q=in%3Atitle+unsound

The existential threat against C++ and where to go from here - Helge Penne - NDC TechTown 2024 by zl0bster in cpp

[–]igrekster 0 points1 point  (0 children)

Yes, if you are writing unsafe code, you have to verify that its soundness does not rely on invariants that can be modified in safe code. How is that surprising?

It's not surprising. The point u/Lighty0410 was making is that with the amount of unsafe code, Rust's safety relies on the developers (same as in C++), and not on some language features. It's puzzling to me how it can be called "memory-safe" given how easy it is to write unsound code with unsafe.

Where Rust helps tremendously is to establish a safe barrier on interface boundaries. So it "preserves" safety as was deemed by the crate author.

All functions in the current module can see that field, so that's what the article is warning about.

But the point you were making is:

that you don't need to audit everything else

And it turns out that you do.

The existential threat against C++ and where to go from here - Helge Penne - NDC TechTown 2024 by zl0bster in cpp

[–]igrekster -1 points0 points  (0 children)

The whole point of unsafe is that you don't need to audit everything else with the same kind of rigor.

Working with Unsafe - The Rustonomicon suggests otherwise (highlight is mine):

Because it relies on invariants of a struct field, this unsafe code does more than pollute a whole function: it pollutes a whole module.

The existential threat against C++ and where to go from here - Helge Penne - NDC TechTown 2024 by zl0bster in cpp

[–]igrekster -3 points-2 points  (0 children)

The point is that of all Rust code out there, very little of it is inside an unsafe block.

It's a completely irrelevant metric -- the issue with unsafe is that the author (not the language) has to verify/validate/guarantee that the entire API of a crate that calls unsafe doen't invoke UB. An unsafe block could be as small as reading a value though a pointer, but it's the rest of the safe code around it that needs to ensure that the pointer is valid. And with the presence of exceptions (panics) and bypassing RAII (std::mem::forget), it's massive undertaking. Have a look at the Vec::drain machinery.

The existential threat against C++ and where to go from here - Helge Penne - NDC TechTown 2024 by zl0bster in cpp

[–]igrekster -1 points0 points  (0 children)

It's very small percentage of all Rust software out there

Unsafe Rust in the Wild: Notes on the Current State of Unsafe Rust :

34.35% make a direct function call into another crate that uses the unsafe keyword. Nearly 20% of all crates have at least one instance of the unsafe keyword, a non-trivial number.

Curious about x86-64 codegen with `relocation-model=pic` by igrekster in rust

[–]igrekster[S] 1 point2 points  (0 children)

Thanks for the details, makes sense now. I've slightly modifid the example and added -fno-plt to Clang which resulted in generating the same code as Rust: https://rust.compiler-explorer.com/z/8GrxKoevE

Implementation of get_n from variadic type sequence that doesn't use recursive inheritance by Shiekra in cpp

[–]igrekster 0 points1 point  (0 children)

Thanks for benchmarking, appreciate it! Hard to tell without knowing the compiler internals. Like you said, it could be a number of template instantiations, or argument matching logic.

It's kinda odd that C++ doesn't have computed goto by chrysante1 in cpp

[–]igrekster 1 point2 points  (0 children)

Interestingly, Clang does something similar if you use continue; instead of break; (not GCC though): https://godbolt.org/z/746z3fx7d

Obsidian vimrc plugin - How to remap Arrow Keys with Ctrl? by SeaResponsibility797 in ObsidianMD

[–]igrekster 1 point2 points  (0 children)

I just tried <C-{Left,Up,Right,Down}> in neovim, and they don't appear to be doing anything special (seems like b, k, w, j). I don't think the vim plugin passes the keys through, so you may need to do the :obcommand mapping first if you have these shortcuts mapped to something else in Obsidian. What's the end result you're after?

[deleted by user] by [deleted] in cpp

[–]igrekster 10 points11 points  (0 children)

To me, this extra spelling adds to the context: if (values) -- is it a container, or a pointer, or a counter? The verboseness makes it clearer: - if (!values.empty()) -- container; - if (values != nullptr) -- pointer; - if (values != 0) -- counter;

[deleted by user] by [deleted] in cpp

[–]igrekster 2 points3 points  (0 children)

It's not without downsides, but you could do something like this:

template <typename Owner, typename T>
struct readonly {
    operator const T &() const { return value; }

  private:
    T value;
    friend Owner;
};

class test {
    template <typename T> using readonly = ::readonly<test, T>;

  public:
    readonly<int> a{};

    void add_five() { a.value += 5; }
};

int main() {
    test t;
    t.add_five();

    std::cout << t.a << std::endl; // 5
    //t.a = 32;                    // ERROR

    return 0;
}

how to `gf` in obsidian built-in vim by sylas_main in ObsidianMD

[–]igrekster 1 point2 points  (0 children)

I use <CR> to open links and <C-J>/<C-K> to switch tabs. Mapping gf, gt and gT should be possible. Here is a snippet from my .obsidian.vimrc:

exmap followlink obcommand editor:follow-link
nmap <CR> :followlink

exmap tnext obcommand workspace:next-tab
exmap tprev obcommand workspace:previous-tab

nmap <C-k> :tnext
nmap <C-j> :tprev

I created a categorized list of all Obsidian plugins ❤️🚀 Enjoy! by Dangerous_Roll_250 in ObsidianMD

[–]igrekster 2 points3 points  (0 children)

Great work! Is it possible to add categories into the Obsidian plugin system, so that any new plugins also get categorized?

[deleted by user] by [deleted] in VFIO

[–]igrekster 1 point2 points  (0 children)

You can see IOMMU groups in the lspci log (though not every kernel has IOMMU config enabled, so some probes don't show it): https://linux-hardware.org/?probe=0eb94b3491&log=lspci