Comments (16)
Ah, that is no good -- I just ran the test on Win 10 (with VS2017) and no problems. Could you build the debug configuration and see if there is a clue?
from mimalloc.
debug configuration if fine.
mimalloc: process init: 0x7fffffde000
mimalloc: debug level : 1
mimalloc: option 'secure': 0
mimalloc: option 'page_reset': 0
heap stats: peak total freed unit count
normal 1: 16 b 16 b 16 b 8 b 2 ok
normal 2: 16 b 16 b 16 b 16 b 1 ok
normal 4: 32 b 64 b 64 b 32 b 2 ok
normal 9: 80 b 80 b 80 b 80 b 1 ok
heap stats: peak total freed unit count
normal: 144 b 176 b 176 b 1 b ok
huge: 0 b 0 b 0 b 1 b ok
total: 144 b 176 b 176 b 1 b ok
malloc requested: 176 b
committed: 12.0 kb 12.0 kb 12.0 kb 1 b ok
reserved: 0 b 0 b 0 b 1 b ok
reset: 0 0 0
segments: 0 0 0
-abandoned: 0 0 0
pages: 3 3 3
-abandoned: 0 0 0
-extended: 3
mmaps: 0
mmap fast: 0
mmap slow: 0
threads: 0
searches: 0.0 avg
elapsed: 0.000 s
process: user: 0.000 s, system: 0.000 s, faults: 739, reclaims: 0, rss: 2.9 m
b
mimalloc: option 'show_stats': 0
heap stats: peak total freed unit count
normal 1: 16 b 16 b 24 b 8 b 2 ok
normal 2: 16 b 16 b 16 b 16 b 1 ok
normal 4: 32 b 64 b 64 b 32 b 2 ok
normal 9: 80 b 80 b 80 b 80 b 1 ok
normal 28: 2.0 kb 2.0 kb 0 b 2.0 kb 1 not all free
d!
heap stats: peak total freed unit count
normal: 2.1 kb 2.2 kb 184 b 1 b not all free
d!
huge: 0 b 0 b 0 b 1 b ok
total: 2.1 kb 2.2 kb 184 b 1 b not all free
d!
malloc requested: 2.2 kb
committed: 12.0 kb 16.0 kb 24.0 kb 1 b ok
reserved: 0 b 0 b 0 b 1 b ok
reset: 0 0 0
segments: 0 0 0
-abandoned: 0 0 0
pages: 3 4 6
-abandoned: 0 0 0
-extended: 4
mmaps: 0
mmap fast: 0
mmap slow: 0
threads: 0
searches: 0.0 avg
elapsed: 0.014 s
process: user: 0.016 s, system: 0.000 s, faults: 746, reclaims: 0, rss: 2.9 m
b
mimalloc: process done: 0x7fffffde000
G:\GitProjects\mimalloc\ide\vs2017\..\..\out\msvc-x64\Debug\mimalloc-override-te
st.exe (process 20756) exited with code 0.
Press any key to close this window . . .
from mimalloc.
ah I see. I don't have a Win 7 system at hand to reproduce the problem but I will look into it. Can you try building the release version of mimalloc with just debug info and see if the problem still happens? (it might be related to differences in the ucrtbase.dll in the debug and release versions)
from mimalloc.
I have try it, still crashed. It's seams the release version not get patched.If I modify the code free(s)
to mi_free(s)
, release version will fine.
main-override.cpp
int main() {
mi_stats_reset();
atexit(free_p);
void* p1 = malloc(78);
void* p2 = malloc(24);
free(p1);
p1 = malloc(8);
char* s = mi_strdup("hello\n");
free(p2);
p2 = malloc(16);
p1 = realloc(p1, 32);
free(p1);
free(p2);
mi_free(s);//free(s);
mi_collect(true);
mi_stats_print(NULL);
return 0;
}
from mimalloc.
Hmm, can you verify if the mi_stats_print
output shows that the other malloc
and free
calls were actually redirected at all to mimalloc? (the output should match the debug one except for the strdup).
What if you leave the free(s)
but use strdup
instead of mi_strdup
?
from mimalloc.
The output not match the debug one. It's seams the release version patch failed.
use strdup
and free
output:
heap stats: peak total freed unit count
elapsed: 0.000 s
process: user: 0.000 s, system: 0.000 s, faults: 613, reclaims: 0, rss: 2.4 m
b
from mimalloc.
Ah, sorry, you also need to define #define MI_STAT 2
in the mimalloc-types.h
header file or the release version won't keep statistics. Can you try that?
from mimalloc.
The dev branch seems crashing on Windows even in debug buiild. Master branch is fine. Looks like override failed to take effect there.
from mimalloc.
Thanks! I am on it. Currently redoing the low-level OS allocation code on the dev
branch and looking into it.
from mimalloc.
Ah, it turns out that adding virtualalloc2 for aligned allocations on windows caused both msvcrt and ucrtbase to be loaded at the same time which both declare entry points for allocation functions -- I now ensure to only patch the ucrtbase which seems to fix this. Commit dev 9390642 available on the latest dev
branch should fix this.
from mimalloc.
@sniper00: I hope that also fixes the issue on Win 7 -- let me know
from mimalloc.
Unfortunately still crashed.
G:\GitProjects\mimalloc>git log --stat
commit 93906428798ff6f4e1b71bf2afc087f6920dddf6 (HEAD -> dev)
from mimalloc.
Ah, i pushed more possible fixes recently -- can you try the latest dev branch? Fingers crossed
from mimalloc.
and I still meet the crash in the latest dev branch. As in the beginning.
use strdup
and free
is fine, output:
heap stats: peak total freed unit count
normal 1: 8 b 8 b 8 b 8 b 1 ok
heap stats: peak total freed unit count
normal: 8 b 8 b 8 b 1 b ok
huge: 0 b 0 b 0 b 1 b ok
total: 8 b 8 b 8 b 1 b ok
malloc requested: 8 b
reserved: 0 b 0 b 0 b 1 b ok
committed: 0 b 0 b 0 b 1 b ok
reset: 0 0 0
touched: 4.0 kb 4.0 kb 4.0 kb 1 b ok
segments: 0 0 0
-abandoned: 0 0 0
pages: 1 1 1
-abandoned: 0 0 0
-extended: 1
mmaps: 0
mmap fast: 0
mmap slow: 0
commits: 0
threads: 0
searches: 0.0 avg
elapsed: 0.000 s
process: user: 0.000 s, system: 0.000 s, faults: 870, reclaims: 0, rss: 3.4 m
b
G:\GitProjects\mimalloc\ide\vs2017\..\..\out\msvc-x64\Release\mimalloc-override-
test.exe (process 19432) exited with code 0.
Press any key to close this window . . .
from mimalloc.
I pushed more potential fixes on the latest dev branch. (I really need to get a Win7 machine to test properly... but for now thank you for testing!).
If it still crashes, please run with MIMALLOC_VERBOSE=2
(which is enabled in the Visual Studio project already) and send the trace messages which should show all the DLL patched entry points. Thanks!
from mimalloc.
Release version is ok ,and the output same as the Debug one. Well done.
from mimalloc.
Related Issues (20)
- std::string destructor causing mimalloc exception HOT 4
- 2.1.2 Windows 11: abort() called from _mi_segment_of() on "foreign" pointer HOT 2
- 'crtdbg.h' with 'mimalloc/mimalloc-override.h' HOT 4
- This repo is missing important files
- Code comment for `mi_page_t.used` possibly incorrect HOT 1
- Override a couple additional C++ delete symbols HOT 3
- Data race with `mi_page_s`'s `flags` field HOT 2
- Documentation typo: malloc(count, size) = malloc(p, count * size) HOT 1
- tag v1.8.4 and v2.1.4 may be missing HOT 1
- Block sizes for huge pages seem inconsistent HOT 4
- Mismatched use of fiber and thread locals HOT 9
- Multiple large pages per segment cause `mi_segment_insert_in_free_queue` to fail HOT 1
- [Feature Request] Support of `musl libc` HOT 3
- mimalloc vs2015 debug version is slower than windows malloc, is there any option to accelerate the speed?
- mimalloc vs2015 debug version is slower than windows malloc, is there any option to accelerate the speed?
- Debug memory allocation HOT 1
- `slice_count` overflow for very large allocations HOT 2
- Calling mi_heap_collect does not decommits all unused pages HOT 2
- `unix/prim.c` uses deprecated Apple `TARGET_` symbols HOT 1
- Patching a 32-bit image with `minject` doesn't tell you to use `minject32`. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mimalloc.