Giter Site home page Giter Site logo

heapwatch's People

Contributors

glagolig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

heapwatch's Issues

Invalid index

Program terminated with signal SIGSEGV, Segmentation fault.
194 entry = entriesByDataHash[stackHash];
(gdb) bt
#0 0xb778225d in ReferenceStack () at StackStorage.c:194
#1 0xb778179d in malloc (size=size@entry=352) at Preload.c:218
#2 0xb75e985c in __fopen_internal (filename=filename@entry=0xb77561a7 "/proc/filesystems", mode=mode@entry=0xb7756018 "r", is32=is32@entry=0) at iofopen.c:73
#3 0xb75ebe5b in _IO_fopen64 (filename=0xb77561a7 "/proc/filesystems", mode=0xb7756018 "r") at iofopen64.c:39
#4 0xb774a9b2 in selinuxfs_exists () from /lib/i386-linux-gnu/libselinux.so.1
#5 0xb77428c3 in ?? () from /lib/i386-linux-gnu/libselinux.so.1
#6 0xb7799d77 in call_init (l=, argc=argc@entry=2, argv=argv@entry=0xbffd84d4, env=env@entry=0xbffd84e0) at dl-init.c:78
#7 0xb7799e64 in call_init (env=0xbffd84e0, argv=0xbffd84d4, argc=2, l=) at dl-init.c:36
#8 _dl_init (main_map=0xb77ac938, argc=2, argv=0xbffd84d4, env=0xbffd84e0) at dl-init.c:126
#9 0xb778c10f in _dl_start_user () from /lib/ld-linux.so.2

(gdb) p stackHash
$1 = 4294919899

in a different run, in HashFn:
result = -2552111681634388
STORAGE_SIZE = 1299721
result % STORAGE_SIZE = -539301
(unsigned long)(result % STORAGE_SIZE) = 4294427995

Looks like, for negative values of result in HashFn, values larger than STORAGE_SIZE are possible when the signed values are cast to unsigned.

crash

I was seeing a crash because RealMalloc hadn't been assigned because the Init() constructor wasn't called.

LD_PRELOAD=./heapwatch_32.so ls
Segmentation fault (core dumped)
#0 0x00000000 in ?? ()
#1 0xb7737792 in malloc (size=size@entry=352) at Preload.c:216
#2 0xb759f85c in __fopen_internal (filename=filename@entry=0xb770c1a7 "/proc/filesystems", mode=mode@entry=0xb770c018 "r", is32=is32@entry=0) at iofopen.c:73
#3 0xb75a1e5b in _IO_fopen64 (filename=0xb770c1a7 "/proc/filesystems", mode=0xb770c018 "r") at iofopen64.c:39
#4 0xb77009b2 in selinuxfs_exists () from /lib/i386-linux-gnu/libselinux.so.1
#5 0xb76f88c3 in ?? () from /lib/i386-linux-gnu/libselinux.so.1
#6 0xb774fd77 in call_init (l=, argc=argc@entry=2, argv=argv@entry=0xbffbbd14, env=env@entry=0xbffbbd20) at dl-init.c:78
#7 0xb774fe64 in call_init (env=0xbffbbd20, argv=0xbffbbd14, argc=2, l=) at dl-init.c:36
#8 _dl_init (main_map=0xb7762938, argc=2, argv=0xbffbbd14, env=0xbffbbd20) at dl-init.c:126
#9 0xb774210f in _dl_start_user () from /lib/ld-linux.so.2

Instead of using the attribute((constructor)), I changed Init() to be called on first use of malloc. Obviously, this doesn't help if malloc isn't the first function called (i.e., calloc, valloc, posix_memalign are called before Init() is called)

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.