memutils icon indicating copy to clipboard operation
memutils copied to clipboard

mlock return -1

Open skoppe opened this issue 8 years ago • 7 comments

in securepool.d@224:
logError("Could not mlock " ~ to!string(pool_size) ~ " bytes");

mlock actually returns -1, which is weird since it is not a valid return value http://linux.die.net/man/2/mlock.

I'm running dmd v2.067 on ArchLinux in boot2docker on windows machine.

My app doesn't use the securepool so it will still compile and run.

skoppe avatar Aug 09 '15 03:08 skoppe

Can you get the errno for this?

import core.stdc.errno;
logError("Could not mlock " ~ to!string(pool_size) ~ " bytes: " ~ errno());

I forgot to log it. The -1 is return value for error, I get this often in the travis docker

etcimon avatar Aug 09 '15 03:08 etcimon

12

think it is ENOMEM

Some of the specified address range does not correspond to mapped pages in the address space of the process.

skoppe avatar Aug 09 '15 04:08 skoppe

I think this might be a problem with ulimit -l setting, the memlock max. I should probably silence this error some way unless secure pool is being used. There's a great security advantage to using mlock'ed memory to avoid leaking crypto keys or passwords on the HDD through swapping/sleeping for example.

etcimon avatar Aug 09 '15 04:08 etcimon

The problem could also be that the box I am running this on is memory restricted, and linux is already (or about to start) swapping.

I am a proponent of docker but it always feels strange that one requires a full OS and at least 512mb ram to run a single process that only takes up 10mb.

skoppe avatar Aug 09 '15 23:08 skoppe

I explored this issue again and it seems like there's a big rabbit-hole of problems with locking memory in docker: https://medium.com/@thejasongerard/resource-limits-mlock-and-containers-oh-my-cca1e5d1f259

I'm not sure how I could fix this in the library itself.

By the way, I've been working a lot with your spasm library, I setup memutils in it and removed the garbage collector in favor of memutils.scoped, made all the firefox bindings work through the generator with more syntax for the official webidl (the most common go through generic functions, the rest through VarArgs), added lodash lodash.d, a router and I'm working on integrating mir to have phobos-like capability and add mir.ion for serialization. The diet templates are cool but they depend on Fast and I need to switch out of it because it's GPL3

This is the last working commit: https://github.com/etcimon/libwasm/commit/005df6bcc0a1a22622193515b86150907ce4ba53

The newer one will compile only once I'm done making everything from mir work with dub test (folders core/ algorithms/). My goal is to be able to develop UI tools directly in webassembly, such as grids, and replace React for building websites.

I changed the name because it would probably be hard for it to be merged anyways.

It compiles only with this version of LDC that adds support for new in betterC ctfe: https://github.com/etcimon/ldc

This is my test file: https://github.com/etcimon/libwasm/blob/master/examples/dom/source/app.d

etcimon avatar Feb 23 '23 16:02 etcimon

I explored this issue again and it seems like there's a big rabbit-hole of problems with locking memory in docker: https://medium.com/@thejasongerard/resource-limits-mlock-and-containers-oh-my-cca1e5d1f259

I'm not sure how I could fix this in the library itself.

Yeah, no problem, I moved on in the 7 year since :smile:

By the way, I've been working a lot with your spasm library, I setup memutils in it and removed the garbage collector in favor of memutils.scoped, made all the firefox bindings work through the generator with more syntax for the official webidl (the most common go through generic functions, the rest through VarArgs), added lodash lodash.d, a router and I'm working on integrating mir to have phobos-like capability and add mir.ion for serialization. The diet templates are cool but they depend on Fast and I need to switch out of it because it's GPL3

Awesome, that is good to hear. I have been meaning to get back to it, but work is in the way. I have some ideas on completing the druntime wasm port I started, supporting the GC etc., but it requires a lot of spelunking. Unsure when it is done. I hope to manage before dconf, but no guarantees.

This is the last working commit: etcimon/libwasm@005df6b

Cool. Will check it out when back from holiday.

I changed the name because it would probably be hard for it to be merged anyways.

No problem, the library is a bit dead, and while I have some fresh ideas, they will likely major rewrite.

skoppe avatar Feb 24 '23 09:02 skoppe

No problem, the library is a bit dead, and while I have some fresh ideas, they will likely major rewrite.

What I have been meaning to do, is use diet templates to have dynamically generated html, which is then merged (or not) recursively to populate the spasm structs or simply set the innerHTML. So basically it calls update on everything that changed through the HTML, and to accomodate missing fields the Node mixin would include a way to add attributes and properties that are used when applying changes to the DOM. That way, you can have a diet template that has a ton of slightly dynamic content elements without needing to build a ton of nodes for it.

The problem is that I'm waiting on a pull request in DMD. And then it has to merge into LDC.

https://github.com/dlang/dmd/pull/14676

etcimon avatar Feb 24 '23 17:02 etcimon