GithubHelp home page GithubHelp logo

Comments (6)

mjp41 avatar mjp41 commented on September 18, 2024

@davidchisnall I had a look, and Trieste seems to be including snmallocshim-static, which I thought would be correct? Could you post me a repro, so I can investigate further?

from rego-cpp.

davidchisnall avatar davidchisnall commented on September 18, 2024

https://github.com/CHERIoT-Platform/cheriot-audit

Linking on macOS, we call __cxa_demangle, which is provided by /usr/lib/libc++.1.dylib. This gets its malloc symbol from /usr/lib/libSystem.B.dylib.

Running this test:

https://github.com/CHERIoT-Platform/cheriot-audit/blob/main/Tests/demangle_compartment_call.query

Crashes with a malloc error if this malloc is too small:

https://github.com/CHERIoT-Platform/cheriot-audit/blob/8192fd3857d93e20bbe6bffbe177a6c942c9e780/audit.cc#L132

I've added a hack to make it try to guess an adequate size.

In general, a library replacing malloc for an entire program is not a good idea. It would be nice if Trieste had an option to use snmalloc, but didn't do it unconditionally, then we could turn it off.

from rego-cpp.

davidchisnall avatar davidchisnall commented on September 18, 2024

(Note: for that specific case, I can pass nullptr to force the callee to allocate, but then I get back a malloc'd pointer and I need to free it with the system malloc. I'm not sure what happens if I pass it to snmalloc's free)

from rego-cpp.

mjp41 avatar mjp41 commented on September 18, 2024

(Note: for that specific case, I can pass nullptr to force the callee to allocate, but then I get back a malloc'd pointer and I need to free it with the system malloc. I'm not sure what happens if I pass it to snmalloc's free)

Another crash.

from rego-cpp.

mjp41 avatar mjp41 commented on September 18, 2024

https://github.com/CHERIoT-Platform/cheriot-audit

Linking on macOS, we call __cxa_demangle, which is provided by /usr/lib/libc++.1.dylib. This gets its malloc symbol from /usr/lib/libSystem.B.dylib.

Running this test:

https://github.com/CHERIoT-Platform/cheriot-audit/blob/main/Tests/demangle_compartment_call.query

Crashes with a malloc error if this malloc is too small:

https://github.com/CHERIoT-Platform/cheriot-audit/blob/8192fd3857d93e20bbe6bffbe177a6c942c9e780/audit.cc#L132

I've added a hack to make it try to guess an adequate size.

In general, a library replacing malloc for an entire program is not a good idea. It would be nice if Trieste had an option to use snmalloc, but didn't do it unconditionally, then we could turn it off.

Probably best to have it off by default, and then we can turn it on where we know it works. It is already off for Windows as that doesn't work.

from rego-cpp.

matajoh avatar matajoh commented on September 18, 2024

I've updated to the latest version of Trieste, which has an explicit flag to disable snmalloc new override, which I believes resolves this issue.

from rego-cpp.

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.