Giter VIP home page Giter VIP logo

Comments (16)

daanx avatar daanx commented on May 22, 2024

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.

sniper00 avatar sniper00 commented on May 22, 2024

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.

daanx avatar daanx commented on May 22, 2024

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.

sniper00 avatar sniper00 commented on May 22, 2024

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.

daanx avatar daanx commented on May 22, 2024

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.

sniper00 avatar sniper00 commented on May 22, 2024

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.

daanx avatar daanx commented on May 22, 2024

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.

junhuaw avatar junhuaw commented on May 22, 2024

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.

daanx avatar daanx commented on May 22, 2024

Thanks! I am on it. Currently redoing the low-level OS allocation code on the dev branch and looking into it.

from mimalloc.

daanx avatar daanx commented on May 22, 2024

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.

daanx avatar daanx commented on May 22, 2024

@sniper00: I hope that also fixes the issue on Win 7 -- let me know

from mimalloc.

sniper00 avatar sniper00 commented on May 22, 2024

Unfortunately still crashed.

G:\GitProjects\mimalloc>git log --stat
commit 93906428798ff6f4e1b71bf2afc087f6920dddf6 (HEAD -> dev)

from mimalloc.

daanx avatar daanx commented on May 22, 2024

Ah, i pushed more possible fixes recently -- can you try the latest dev branch? Fingers crossed

from mimalloc.

sniper00 avatar sniper00 commented on May 22, 2024

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.

daanx avatar daanx commented on May 22, 2024

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.

sniper00 avatar sniper00 commented on May 22, 2024

Release version is ok ,and the output same as the Debug one. Well done.

from mimalloc.

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.