jemalloc and JVM_FindSignal - memory

As already answered in this question:
JVM_FindSignal function continuously allocates native memory
jemalloc reporting leaks from JVM_FindSignal is related to missing debug symbols. I certainly have debugging symbols installed, see:
rbs42#rbs42-VirtualBox:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/amd64/server$ gdb libjvm.so -ex 'info address UseG1GC'
GNU gdb (Ubuntu 9.1-0ubuntu1) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from libjvm.so...
Reading symbols from /usr/lib/debug/.build-id/16/240e0172c3fc0dd6e974325c8ad1d93723ccac.debug...
(No debugging symbols found in /usr/lib/debug/.build-id/16/240e0172c3fc0dd6e974325c8ad1d93723ccac.debug)
Installing openjdk unwinder
Traceback (most recent call last):
File "/usr/share/gdb/auto-load/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so-gdb.py", line 52, in <module>
class Types(object):
File "/usr/share/gdb/auto-load/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so-gdb.py", line 66, in Types
nmethodp_t = gdb.lookup_type('nmethod').pointer()
gdb.error: No type named nmethod.
Symbol "UseG1GC" is at 0xd189b2 in a file compiled without debugging.
still my jeprof output looks as following:
rbs42#rbs42-VirtualBox:/media/rbs42/data/Gebos/RBS42/run/sms50$ jeprof --show_bytes /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java jeprof.22104.0.f.heap
Using local file /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java.
Using local file jeprof.22104.0.f.heap.
Welcome to jeprof! For help, type 'help'.
(jeprof) top
Total: 33502504 B
20958503 62.6% 62.6% 21342909 63.7% JVM_FindSignal
8388608 25.0% 87.6% 8388608 25.0% SNX11B1A
1481379 4.4% 92.0% 1481379 4.4% inflate
1151253 3.4% 95.5% 1151253 3.4% Java_java_util_zip_ZipFile_getZipMessage
426303 1.3% 96.7% 426303 1.3% SNE00B1A
404065 1.2% 97.9% 404065 1.2% inflateInit2_
253077 0.8% 98.7% 20393297 60.9% SUNWprivate_1.1
176271 0.5% 99.2% 176271 0.5% std::__throw_ios_failure
131713 0.4% 99.6% 131713 0.4% _dl_new_object
131328 0.4% 100.0% 131328 0.4% _dl_check_map_versions
(jeprof)
Is there anything else to consider?

It turns out that
openjdk-8-dbg package installs files with debug symbols into /usr/lib/debug/.build-id
jeprof looks for debug symbols in /usr/lib/debug/{FULL_SO_PATH}
So, it's a combination of a bug in jeprof that does not parse .note.gnu.build-id section, and a problem of the dbg package that does not include full path symlinks to debug libraries.
To work around this, you may create the corresponding symlink manually:
ln -s /usr/lib/debug/.build-id/16/240e0172c3fc0dd6e974325c8ad1d93723ccac.debug /usr/lib/debug/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so
(the file names are taken from gdb output)
However, even when jeprof is able to read debug symbols, this doesn't often help in case of Java applications. The problem is that jemalloc doesn't know how to unwind Java stacks. See this presentation for an example.
Consider trying async-profiler that can show mixed Java+native stacks. Profiling malloc, mprotect and mmap calls with async-profiler can be helpful in finding native memory leaks in Java applications. See this answer for details.

Here is a patch for jeprof that makes it smarter about finding debug symbols. It's based on #apangin's answer.
https://github.com/jemalloc/jemalloc/pull/2059/files

Related

AddressSanitizer memcpy-param-overlap errors with std::string with visual studio 2019

I'm using address sanitizer (ASAN) with visual studio 2019 (version 16.9.2) on windows.
ASAN is reporting lots of errors and almost all of them are memcpy-param-overlap.
They are related usage of std::string.
==13388==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x2141a3ba,0x2141a3cb) and [0x2141a3b0, 0x2141a3c1) overlap
#1 0x16d3e32 in std::basic_string<char,std::char_traits<char>,std::allocator<char> >::insert C:\VS2019\VC\Tools\MSVC\14.25.28610\include\xstring:3006
#2 0x16ae413 in std::operator+<char,std::char_traits<char>,std::allocator<char> > C:\VS2019\VC\Tools\MSVC\14.25.28610\include\xstring:4346
Here is another instance
==13388==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x214239ba,0x214239cb) and [0x214239b0, 0x214239c1) overlap
#1 0x16d3e32 in std::basic_string<char,std::char_traits<char>,std::allocator<char> >::insert C:\VS2019\VC\Tools\MSVC\14.25.28610\include\xstring:3006
#2 0x16ae413 in std::operator+<char,std::char_traits<char>,std::allocator<char> > C:\VS2019\VC\Tools\MSVC\14.25.28610\include\xstring:4346
There are lots of these and all the errors are similar to above.
I don't know what I'm missing here. Is this related to std libraries.
Any hints/direction would be helpful.

How do I tell clang memory sanitizer to ignore data from certain libraries?

For example I'd like to ignore sqlite and zlib because I know they're well tested. I grabbed the zpipe.c example and built it like this. Keep in mind I'm using -lz and not building zlib myself. I'm only building zpipe myself and want to limit the sanitize to that one file
clang -g -fsanitize=undefined,memory zpipe.c -lz
I ran echo Test | ./a.out and I got the following error
Uninitialized bytes in __interceptor_fwrite at offset 0 inside [0x7ffd61230bc0, 13)
==50435==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x55767941cd85 in def /tmp/zlib-1.2.12/examples/zpipe.c:70:17
#1 0x55767941e709 in main /tmp/zlib-1.2.12/examples/zpipe.c:186:15
#2 0x7f65e834e30f in __libc_start_call_main libc-start.c
#3 0x7f65e834e3c0 in __libc_start_main#GLIBC_2.2.5 (/usr/lib/libc.so.6+0x2d3c0)
#4 0x5576793981d4 in _start (/tmp/zlib-1.2.12/examples/a.out+0x211d4)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /tmp/zlib-1.2.12/examples/zpipe.c:70:17 in def
Is there a way I can say assume any data that goes in and out of zlib or sqlite to be safe to use? I'll be linking both and only want to sanitize my own code
You can use an ignore list file. https://clang.llvm.org/docs/SanitizerSpecialCaseList.html
Usage:
clang -fsanitize=address -fsanitize-ignorelist=ignorelist.txt foo.c
See the documentation for details on the format of the file.

Need help installing the GNU Scientific Library for Lisp(GSLL)

I use Emacs\Slime\SBCL\QuickLisp\Cygwin(new to Cywgin I know nothing really about it) I, per this GNU link http://common-lisp.net/project/gsll/, tried to follow these instructions under the download and install section:
"You will need to make sure that the libraries and header files associated with GNU Scientific Library (GSL) and libffi are installed; your distribution may name these libgsl0-dev and libffi-dev. Once they are installed and you have loaded the quicklisp file:
run (ql:quickload "gsll")"
but its not working . I get this error message in emacs when running (ql:quickload "gsll")
Unable to load any of the alternatives:
("libffi-6.dll" "libffi-5.dll" "libffi.dll")
[Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
I have quicklisp installed correctly i use it all the time so I know its not that ....I don't really understand this part of above excerpt from website(above)
"your distribution may name these libgsl0-dev and libffi-dev." Once they are installed and you have loaded the quicklisp file"
well I do kind of and quicklisp can't seem to find them with "(ql:system-apropos "libffi")" or "(ql:system-apropos "libffi")" also the website(above link) names these dependencies, I think here in this exerpt:
"Requirements
GSLL should work in any Common Lisp implementation and platform combination for which the following are supported:
GSL
CFFI and cffi-grovel, version 0.11.0 or newer; callbacks and foreign-funcall must be supported.
trivial-garbage
Antik
ASDF
Osicat
lisp-unit, (Optional) necessary to run the tests
FSBV, (Optional) necessary for functions using complex scalars or simulated annealing
iterate and asdf-system-connnections, (Optional) provides a convenient way to iterate over elements or indices of vectors or matrices."
of the above I have CFFI CFFI-Grovel,trivial garbage, asdf,iterate ,Antik(all from quicklisp) but still can't figure it out please help me with step by step instructions for Windows 8 64-bit with perfectly functioning Emacs\Slime\SBCL\QuickLisp\Cygwin installed and available...I would appreciate any and all advice..Thank You
Note: now of these - Excerpt from website http://comments.gmane.org/gmane.lisp.gsll/257"
To load "gsll":
Load 3 ASDF systems:
alexandria cl-ppcre split-sequence
Install 20 Quicklisp releases:
antik asdf-system-connections babel bordeaux-threads
cffi chunga cl+ssl cl-base64 drakma flexi-streams fsbv
gsll iterate osicat puri static-vectors
trivial-features trivial-garbage trivial-gray-streams
usocket"
I have all but Osicat. GSLL, and fsbv. When I try to load GSLL with
(ql:quickload "gsll")
I get:
Error while trying to load definition for system gsll from pathname
D:/Users/W/AppData/Roaming/quicklisp/dists/quicklisp/software/gsll-20130312-git/gsll.asd:
Unable to load any of the alternatives:
("libffi-6.dll" "libffi-5.dll" "libffi.dll")
[Condition of type ASDF:LOAD-SYSTEM-DEFINITION ERROR]
When I try to load Osicat with
(ql:quickload "osicat")
I get:
Error while invoking <COMPILE-OP (:VERBOSE NIL) {26FB8F59}> on
<CL-SOURCE-FILE "osicat" "src" "osicat">
[Condition of type ASDF:COMPILE-ERROR]
and quicklisp doesn't have FSBV.....Any Help would be appreciated.
;;;;;;;;;;;;;;;;EDIT;;;;;;;;;;;;;;;;;;;
#Nelson
Made new progress on this one ...I got past the:
"Error while trying to load definition for system gsll from pathname
D:/Users/W/AppData/Roaming/quicklisp/dists/quicklisp/software/gsll-20130312-git/gsll.asd:
Unable to load any of the alternatives:
("libffi-6.dll" "libffi-5.dll" "libffi.dll")
[Condition of type ASDF:LOAD-SYSTEM-DEFINITION ERROR]"
Error Message when I ran (ql:quickload "gsll") in Emacs. I did it by downloading the LIBFFI tarball from here:
http://sourceware.org/libffi/ ..the link at the top of page.
then i followed this tutorial http://phosphor-escence.blogspot.com/2011/08/build-libffi-and-libyaml-on-mingw-for.html
to build LIBFFI with a correctly installed MinGW(installed at C:\MinGW)
I learned to install MinGw correctly here: http://www.mingw.org/wiki/Getting_Started
after building LIBFFI I added its path - D:\libffi-3.0.13 - to my "system" Environment Variables "path" variable:
D: is my root drive.
I searched the D:\libffi-3.0.13 folder in Windows Explorer by putting *.dll in search bar, found libffi-6.dll
and put it in D:\Program Files (x86)\Steel Bank Common Lisp\1.1.4 so SBCL could access it , the libffi-6.dll
was named in the previous error message:
Error while trying to load definition for system gsll from pathname
D:/Users/W/AppData/Roaming/quicklisp/dists/quicklisp/software/gsll-20130312-git/gsll.asd:
Unable to load any of the alternatives:
("libffi-6.dll" "libffi-5.dll" "libffi.dll")
[Condition of type ASDF:LOAD-SYSTEM-DEFINITION ERROR]
Jobs not done though...now I'm getting this Error Message, Which I will start on Tomorrow:
"Error while trying to load definition for system gsll from
pathname
D:/Users/W/AppData/Roaming/quicklisp/dists/quicklisp/software/gsll-20130312-git/gsll.asd:
External process exited with code 1.
Command was: "C:/MinGW/bin/gcc.exe" "-m32" "-I/Program Files (x86)/Steel Bank Common Lisp/1.1.4/site/cffi/" "-o" "D:\Program Files (x86)\Steel Bank Common Lisp\1.1.4\site\cffi\libffi\libffi-win32.exe" "D:\Program Files (x86)\Steel Bank Common Lisp\1.1.4\site\cffi\libffi\libffi-win32.c"
Output was:
[Condition of type ASDF:LOAD-SYSTEM-DEFINITION-ERROR]"
Any help in the meantime would be appreciated:
;;;;;;;;;;SOLVED;;;;;;;;;;
A Tutorial link for it is coming soon and will posted right
under this point<-----here.
Here it is Fellow Lispers..I give you GSLL on Windows 7 AND 8: https://wnetai.wordpress.com/how-to-install-gsll_the-gnu-scientific-library-for-lisp-on-windows-7-and-windows-8/
and here is a link of GSLL Error Mesages and their Solutions: https://wnetai.wordpress.com/how-to-install-gsll_the-gnu-scientific-library-for-lisp-on-windows-7-and-windows-8/error-message-you-may-get-when-installing-gsll-and-their-solutions/
I'm working on a Database of Code Snippets for GSLL starting with Linear Algebra which will be on the same Blog as those upper two links so stay tuned here and on my Lisp Blog for those. Its basically a How to use GSLL Tutorial made with Code Snippets, Descriptions of the Snippets and Examples.
Your problem is that the development version of libffi (with header files) is not installed. There might be windows users on the cffi-devel mailing list that could help you with that; I recommend you post your question there. As far as the lisp libraries are concerned, quicklisp should take care of that and they are irrelevant to your problem. (And also, FSBV is obsolete and not needed; thanks for pointing out that the documentation needs to be updated.) (Also, emacs and slime are irrelevant to the problem, tags should be removed.)
It seems like you need to install those libraries into your system, you'll have to find the windows equivalents.
For debian/ubuntu : http://pkgs.org/download/libffi-dev
These aren't installed through quicklisp but through the system package manager, in your case you will have to find a windows compatible version and install it.
Any luck with getting GSLL to work on Windows 7? I've been trying to install the software and
have even used Dependency Walker to track any missing DLLs that might be needed but still have not been able to get it to run. I do have it running fine on Linux but I am looking to have it running under Window 7.

Runtime exception(s) when running an F# benchmark on Mono

I am trying to compare the performance of a specific F# benchmark running on .NET and Mono 2.10.2 (Windows 7, 64-bit). I took the Spectral-Norm benchmark from the Benchmarks Game followed the traditional SO advice of using System.Diagnostics.StopWatch for benchmarking C# and added the lines 4, 89-90, and 93-95 at this link. I compiled this code in Visual Studio 2010 (For runtime 4.0, not client profile, any CPU, with optimize code and tail calls turned on). The compiled code runs just fine on .NET (including inside VS), but when I run the .exe on Mono with "mono shootout_spectralnorm.exe" I get the following error (repeated in the fssnip.net link):
Unhandled Exception: System.TypeInitializationException: An exception was thrown
by the type initializer for System.Diagnostics.Stopwatch ---> System.InvalidPro
gramException: Invalid IL code in System.Diagnostics.Stopwatch:.cctor (): method
body is empty.
--- End of inner exception stack trace ---
at Program.main (System.String[] args) [0x00000] in <filename unknown>:0
The strange thing is, when I remove the lines I had added (lines 4, 89-90, and 93-95, which relate to the timing part of the benchmark), the error goes away on Mono, and it acts just like it does on MS .NET. This is just baffling me. I set all of the referenced assemblies in VS to be copied locally, so they should be visible to Mono, but there could be some precedence issue with different assemblies in the GAC that have the same name as the ones in the local folder. Has anyone encountered this issue or a similar one, especially on Windows Mono? If so, or if you think you know how this problem could be fixed, I hope you can help me resolve it.
Reference Assemblies do not (often) have code - they are API signatures only (enough info for the compiler to reference them at design-time/compile-time). You need to copy the runtime assemblies, not the reference assemblies, in order to run it. (You'll often find the runtime assemblies in the GAC.)
Here are measurements for FSharp-2.0.0.0 spectral-norm #2 (Intel Q6600 quad-core, MS Vista 32 bit)
fsc CPU s Elapsed s
500 0.281 0.337
3000 4.883 1.453
5500 15.85 4.212
2.10.2 CPU s Elapsed s
500 0.343 2.222
3000 4.836 3.361
5500 15.912 6.153
C:/Mono-2.10.2/bin/mono.exe C:/FSharp-2.0.0.0/bin/fsc.exe --platform:x86
--optimize+ --out:spectralnorm.exe spectralnorm.fsharpmono-2.fs
C:/Mono-2.10.2/bin/mono.exe --gc=sgen spectralnorm.exe 5500
Now the benchmarks game spectral-norm on MS Vista demo, includes F# on Mono.

Issues with SWI-Prolog editor

Some time ago I was fiddling with SWI-Prolog editor, trying to get something to work, and I change some configuration settings. It didn't work so I changed it back. Now SWI-Prolog editor is not working correctly. I will load files but when I click 'consult' it will just throw this error:
consult('C:/Users/Cubearth/Documents/Prolog/'filename.pl').
and I am not able to perform queries, on the knowledge base... it just does nothing. I know that it should return:
% library(win_menu) compiled into win_menu 0.00 sec, 20,952 bytes
% library(swi_hooks) compiled into pce_swi_hooks ......... (etc, etc)
For help, use ?- help(Topic). or ?- apropos(Word).
but I am not even getting that. I tried uninstalling both prolog and the editor, but still no luck.
Any ideas on how to fix this?
In order to help, I have included the configuration dump of prolog:
Installation
C:\Program Files (x86)\SWIPrologEditor\SWIMachine.ini
C:\Users\Cubearth\AppData\Roaming\SWIPrologEditor\SWIUser.ini
C:\Users\Cubearth\AppData\Roaming\SWIPrologEditor\SWIColor.ini
[SWI]
PortableApplication=0
Verzeichnis=C:\Program Files\pl
Manual=C:\Program Files\pl\bin\doc\Manual\Contents.html
XPCE=C:\Program Files\pl\bin\doc\UserGuide\Contents.html
[Program]
InterpreterParameter=-L32M
FileExtension=.pl
[Editor]
TabWidth=2
Indent=2
Indenthelp=1
AutomaticIndent=1
FileTab=1
Linenumbering=1
BracketPair=0
CursorBehindLine=1
Author=
Encoding=0
Structure=0
[Code]
Code-Completion=1
Parameter-Hints=1
Delay=100
[Options]
ColoredConsole=1
IntegratedWindow=1
ReturnToContinue=1
TraceStopsDebugToo=1
BAKFiles=1
RemoveWriteProtection=1
FileTabsMultiline=1
Language=C:\Program Files (x86)\SWIPrologEditor\english.ini
[Browser]
UseIEinternForDocuments=1
OnlyOneBrowserWindow=0
Browser=C:\Users\Cubearth\AppData\Local\Google\Chrome\Application\chrome.exe
Title=unknown
AltKeysBrowser=
ProxyEnabled=0
ProxyIP=
ProxyPort=0
[Printer]
Left=20
Top=20
Right=20
Bottom=20
Header=#%PATH%#
Footer=##- %PAGENUM% -
Linenumbers=0
LinenumbersInMargin=1
Let me enlighten the poor lost soul that is cubearth. You should double check to see which version of swi-prolog you installed (32-bit or 64-bit), because swi-prolog editor only works with the 32-bit version. If you tried using the editor with the 64-bit version, you'll get the error described above. ^^ .
p.s. You are welcome.
Enable trace, run cmd --
?- trace. consult('C:/Users/Cubearth/Documents/Prolog/'filename.pl').

Resources