Coder Social home page Coder Social logo

Comments (7)

t-8ch avatar t-8ch commented on June 18, 2024

On which operating system is this? I can't reproduce it on Ubuntu 22.04 as mentioned in the linked python ticket.

(And which version of libuuid?)

from util-linux.

lyc8503 avatar lyc8503 commented on June 18, 2024

That's weird. I can reproduce this on a fresh Ubuntu 22.04.2 LTS install. (I tried it again on a new VPS)
libuuid version: libuuid1/jammy-updates,jammy-security,now 2.37.2-4ubuntu3.4 amd64 [installed,automatic]

root@ubuntu-s-1vcpu-2gb-70gb-intel-sfo3-04:~# uname -a
Linux ubuntu-s-1vcpu-2gb-70gb-intel-sfo3-04 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu-s-1vcpu-2gb-70gb-intel-sfo3-04:~# cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
root@ubuntu-s-1vcpu-2gb-70gb-intel-sfo3-04:~# uuidgen --version
uuidgen from util-linux 2.37.2
root@ubuntu-s-1vcpu-2gb-70gb-intel-sfo3-04:~# gcc uuidtest.c -luuid && ./a.out
before fork: 0 4dd58c2e0a1d11ef84ac73fe09c6a754
after fork: 1528089 0
4dd58c2f0a1d11ef84ac73fe09c6a754
after fork: 0 0
4dd58c2f0a1d11ef84ac73fe09c6a754
root@ubuntu-s-1vcpu-2gb-70gb-intel-sfo3-04:~# cat uuidtest.c 
#include <uuid/uuid.h>
#include <unistd.h>
#include <stdio.h>

int main()
{
    uuid_t uuid;
    printf("before fork: %d ", uuid_generate_time_safe(uuid));
    for (int i = 0; i < 16; i++)
        printf("%02x", uuid[i]);
    printf("\n");

    int ret = fork();
    printf("after fork: %d %d\n", ret, uuid_generate_time_safe(uuid));
    for (int i = 0; i < 16; i++)
        printf("%02x", uuid[i]);
    printf("\n");

    return 0;
}

root@ubuntu-s-1vcpu-2gb-70gb-intel-sfo3-04:~#

from util-linux.

t-8ch avatar t-8ch commented on June 18, 2024

I used the "ubuntu:22.04" docker container, with the exact same version of libuuid.
On my ArchLinux workstation and Debian 12 server it also behaves the same.

from util-linux.

t-8ch avatar t-8ch commented on June 18, 2024

On a similar DO droplet as yours I can reproduce it (unsurprisingly).

from util-linux.

t-8ch avatar t-8ch commented on June 18, 2024

The droplet has the uuidd daemon installed and enabled.
In that case uuid_generate_time_safe() will indeed always return 0.

When going through the daemon I can also reproduce this on the current release of util-linux.

from util-linux.

t-8ch avatar t-8ch commented on June 18, 2024

libuuid has a cache and requests UUIDs from libuuidd in batches. This cache is kept in memory and preserved over fork().

from util-linux.

t-8ch avatar t-8ch commented on June 18, 2024

The weird thing is, that the cache is a thread-local variable.
fork() by definition creates a new thread but the thread-local data is preserved.

from util-linux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.