Coder Social home page Coder Social logo

cbPool storage exhausted about go-yara HOT 9 CLOSED

lpendergrass avatar lpendergrass commented on May 23, 2024
cbPool storage exhausted

from go-yara.

Comments (9)

hillu avatar hillu commented on May 23, 2024 1

@ozanh You're right; the static scan thread limit went away in YARA 4.0 and YR_MAX_THRERAD serves no other purpose than API compatibility.

This means that for practical the number of concurrent YARA threads may be way higher than before – so perhaps it makes sense to be able to grow the callback data structure on demand.

from go-yara.

lpendergrass avatar lpendergrass commented on May 23, 2024

I might not entirely understand here... but would hardcoding this at 256 cause any potential constraints elsewhere if scanning with a large number of rules within a goroutine?

https://github.com/hillu/go-yara/blob/master/util.go#L9

from go-yara.

ozanh avatar ozanh commented on May 23, 2024

Hi @LancePendergrass
As I use the go-yara heavily, I had realized cbPool limit and took some actions to prevent crashes. Under normal circumstances, one cannot easily exceed the cbPool limit but I limit the number of yara scanner goroutines to min(64, 2 * number of CPU). We use go-yara in thousands of machines around the world and I haven't been informed about any bug related to this.

from go-yara.

lpendergrass avatar lpendergrass commented on May 23, 2024

Okay limiting to runtime.NumCPU() and leveraging a similar pattern to below seems to have worked. Thanks.

https://stackoverflow.com/a/25306241

from go-yara.

hillu avatar hillu commented on May 23, 2024

@lpendergrass By default, YARA concurrency is limited to 32 threads. If you limit your program to that value, you still should not run out of cbpool values.

If anyone has a good suggestion how to document the limit (and what those panics actually mean: PRs are welcome, of course.

from go-yara.

ozanh avatar ozanh commented on May 23, 2024

@hillu After my quick text search in yara source code, I couldn't find a limit for yaralib concurrency. YR_MAX_THREADS or ERROR_TOO_MANY_SCAN_THREADS aren't applicable for the library, but are used in yara cli and sandbox folders. Let me know if I missed something and let me know if it can be added to go-yara doc as a concurrency best practice.

from go-yara.

lpendergrass avatar lpendergrass commented on May 23, 2024

Dynamic growth of that cap sounds like the way to go but in lieu of that it might help to document it somewhere or indicate this in the exception message.

https://github.com/hillu/go-yara/blob/master/cbpool.go#L56

from go-yara.

hillu avatar hillu commented on May 23, 2024

Sure. If somebody wants to take a shot at it, I'm open to PRs.

from go-yara.

hillu avatar hillu commented on May 23, 2024

As of 3099294, dbPool has been replöaced with cgo.Handle (or an equivalent implementation that is used on older Go versions).

Closing this issue. Feel free to reopen if the issue comes up again.

from go-yara.

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.