Coder Social home page Coder Social logo

Comments (12)

ifelsefi avatar ifelsefi commented on June 12, 2024

Let me know if I can do anything to troubleshoot.

from xattr.

kuba-- avatar kuba-- commented on June 12, 2024

@fd0 - I'll take a look. Right now we use "golang.org/x/sys/unix" (instead of syscalls), so maybe there is something....

from xattr.

fd0 avatar fd0 commented on June 12, 2024

@kuba-- thanks! I find this error very odd, the machine @ifelsefi used seemed to have enough free memory available, and usually Go panics instead of returning an error when no memory could be allocated... I'm a bit puzzled.

For the record, the commit of xattr in question should be v0.2.3 (1d7b7ff).

from xattr.

kuba-- avatar kuba-- commented on June 12, 2024

@fd0, @ifelsefi - There are 2 places In xattr.List where OOM may happen. One is when we convert path string to byte slice, and the second one is when we allocate memory for a buffer with all attributes. In your case, most likely it happened here:
https://github.com/pkg/xattr/blob/v0.2.3/xattr_linux.go#L37
I don't know if we can do anything with that. Maybe I can add extra check if buf != nil and/or go to the unsafe low level and check memory limits (if I can allocate as much memory as needed).

Can you also check if it's reproducible with the latest?

from xattr.

davecheney avatar davecheney commented on June 12, 2024

from xattr.

fd0 avatar fd0 commented on June 12, 2024

@kuba-- thanks for the hints. @ifelsefi is the user in question and he's now running the latest version of restic which uses 0.3.1. We'll see what he reports. If it persists, I'd like him to run restic on just a single file, when that works out, we can e.g. use strace to see what's going on between the program and the kernel.

What I find odd is that in all cases where I had Go programs which were unable to allocate enough memory, they panic instead of returning an error (especially whith make([]byte, n))...

from xattr.

davecheney avatar davecheney commented on June 12, 2024

from xattr.

kuba-- avatar kuba-- commented on June 12, 2024

@davecheney - the issue was encountered on linux, so most likely it's because sysAlloc returned nil:
https://github.com/golang/go/blob/77f9b2728eb08456899e6500328e00ec4829dddf/src/runtime/mem_linux.go#L21

https://github.com/golang/go/blob/4c1c839a3d2270d846f5a6d1cd1287e8560f0265/src/runtime/malloc.go#L1189
or
https://github.com/golang/go/blob/415e948eaea05930b2a16bab6af9e38b24e8414b/src/runtime/mheap.go#L1673

And because it was xattr + rustic it could be any place where errno is ENOMEM, most likely from mmap:
https://github.com/golang/go/blob/77f9b2728eb08456899e6500328e00ec4829dddf/src/runtime/mem_linux.go#L164

from xattr.

davecheney avatar davecheney commented on June 12, 2024

from xattr.

kuba-- avatar kuba-- commented on June 12, 2024

I understand it happened on linux with version 0.2.3, so if you got an errno 12 from syscall:
https://github.com/pkg/xattr/blob/v0.2.3/xattr_linux.go#L39
Then there is nothing what we can do - we just propagate the error.

from xattr.

kuba-- avatar kuba-- commented on June 12, 2024

@fd0 @ifelsefi - shall I close it? Have you had a time to investigate and/or check the latest version?

from xattr.

fd0 avatar fd0 commented on June 12, 2024

Ah, yes, @ifelsefi reproduced the issue while running strace:

[pid  4640] listxattr("/[...].png", 0x1049ef0, 0) = -1 ENOMEM (Cannot allocate emory)

This looks like it's just ENOMEM returned from the kernel, so in my opinion this library does the right thing. Sorry for the noise and thanks for the support!

from xattr.

Related Issues (18)

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.