View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0004754 | Spring engine | public | 2015-04-23 23:40 | 2015-05-01 18:27 | |||||
Reporter | UnitedMarsupials | ||||||||
Assigned To | abma | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Product Version | 98.0 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0004754: Use of google-perftools breaks things | ||||||||
Description | If google-perftools (and libtcmalloc.so in particular) are present on the system at build-time, spring-executable will dump core at start-up: https://people.freebsd.org/~amdmi3/spring.log I suspect, some mistake causes a pointer returned by regular malloc() to be passed to Google's free(). Building without libtcmalloc.so present produces a usable package. While you are looking at it, is there a way to explicitly disable the use of alternative malloc(s) even if present? | ||||||||
Additional Information | src/tcmalloc.cc:278] Attempt to free invalid pointer 0x812435000 | ||||||||
Tags | No tags attached. | ||||||||
Checked infolog.txt for Errors | |||||||||
Attached Files |
|
![]() |
|
jK (developer) 2015-04-24 01:18 |
tcmalloc works fine here and yes, you can disable it (check cmake-gui .) |
abma (administrator) 2015-04-24 07:43 |
can you provide a stacktrace with gdb please? this line looks weird to me in infolog.txt: [ThreadPool::SetThreadCount][1] #wanted=1 #current=1 #max=1 [ThreadPool::SetThreadCount][2] #threads=0 does test/test_ThreadPool work? |
UnitedMarsupials (reporter) 2015-04-24 15:10 |
> can you provide a stacktrace with gdb please? Of the three threads at time of crash, only one is useful. Here: (gdb) where #0 0x0000000808dfa784 in decode_mcu () from /opt/lib/libjpeg.so.8 #1 0x0000000808df6704 in decompress_onepass () from /opt/lib/libjpeg.so.8 #2 0x0000000808dfc7dc in process_data_simple_main () from /opt/lib/libjpeg.so.8 0000003 0x0000000808df40b7 in jpeg_read_scanlines () from /opt/lib/libjpeg.so.8 0000004 0x0000000802b2def2 in ilLoadFromJpegStruct () from /opt/lib/libIL.so.1 0000005 0x0000000802b2e376 in iLoadJpegInternal () from /opt/lib/libIL.so.1 #6 0x0000000802b2e4ce in ilLoadJpegL () from /opt/lib/libIL.so.1 #7 0x0000000802b54ca0 in ilLoadL () from /opt/lib/libIL.so.1 #8 0x0000000000685cd6 in ?? () #9 0x00000000009e1308 in ?? () Valgrdind reports: ==45510== Command: spring ==45510== ==45510== Invalid write of size 8 ==45510== at 0x7E3D1FD: tcmalloc::Static::InitStaticVars() (in /opt/lib/libtcmalloc.so.4.2.6) ==45510== by 0x7E3E241: tcmalloc::ThreadCache::InitModule() (in /opt/lib/libtcmalloc.so.4.2.6) ==45510== by 0x7E36630: ??? (in /opt/lib/libtcmalloc.so.4.2.6) ==45510== by 0x7E4C5A1: calloc (in /opt/lib/libtcmalloc.so.4.2.6) ==45510== by 0x94600A9: ??? (in /lib/libthr.so.3) ==45510== by 0x9461282: ??? (in /lib/libthr.so.3) ==45510== by 0x9464241: ??? (in /lib/libthr.so.3) ==45510== by 0x9456F7D: ??? (in /lib/libthr.so.3) ==45510== by 0x40040B6: ??? (in /libexec/ld-elf.so.1) ==45510== by 0x40024C8: ??? (in /libexec/ld-elf.so.1) ==45510== Address 0x12d0cc0 is not stack'd, malloc'd or (recently) free'd ==45510== ==45510== ==45510== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==45510== Access not within mapped region at address 0x12D0CC0 ==45510== at 0x7E3D1FD: tcmalloc::Static::InitStaticVars() (in /opt/lib/libtcmalloc.so.4.2.6) ==45510== by 0x7E3E241: tcmalloc::ThreadCache::InitModule() (in /opt/lib/libtcmalloc.so.4.2.6) ==45510== by 0x7E36630: ??? (in /opt/lib/libtcmalloc.so.4.2.6) ==45510== by 0x7E4C5A1: calloc (in /opt/lib/libtcmalloc.so.4.2.6) ==45510== by 0x94600A9: ??? (in /lib/libthr.so.3) ==45510== by 0x9461282: ??? (in /lib/libthr.so.3) ==45510== by 0x9464241: ??? (in /lib/libthr.so.3) ==45510== by 0x9456F7D: ??? (in /lib/libthr.so.3) ==45510== by 0x40040B6: ??? (in /libexec/ld-elf.so.1) ==45510== by 0x40024C8: ??? (in /libexec/ld-elf.so.1) Hope, this helps... > does test/test_ThreadPool work? Yes, all tests -- except for the UDP-one (which fails here, because IPv6 is not enabled on my system) pass. |
abma (administrator) 2015-04-24 16:49 Last edited: 2015-04-24 16:52 |
can you compile spring 98 in debug mode please? sadly this isn't useful: #8 0x0000000000685cd6 in ?? () #9 0x00000000009e1308 in ?? () does it work when you set LoadingMT = 0 ? it looks a bit like sound thread crashes. maybe setting Sound = 0 makes it run? because of Using joystick 0: /dev/uhid0 shortly before crash setting JoystickEnabled = 0 could help, too. (thats all uncommon i saw) |
UnitedMarsupials (reporter) 2015-04-24 20:04 |
> can you compile spring 98 in debug mode please? I did, actually, but the binaries got stripped at install-time :-) Here is the stack of the JPEG-crash: #0 0x0000000808e0d1e4 in jpeg_idct_16x16 () from /opt/lib/libjpeg.so.8 (gdb) where #0 0x0000000808e0d1e4 in jpeg_idct_16x16 () from /opt/lib/libjpeg.so.8 #1 0x0000000808df6844 in decompress_onepass () from /opt/lib/libjpeg.so.8 #2 0x0000000808dfc7dc in process_data_simple_main () from /opt/lib/libjpeg.so.8 0000003 0x0000000808df40b7 in jpeg_read_scanlines () from /opt/lib/libjpeg.so.8 0000004 0x0000000802b2def2 in ilLoadFromJpegStruct () from /opt/lib/libIL.so.1 0000005 0x0000000802b2e376 in iLoadJpegInternal () from /opt/lib/libIL.so.1 #6 0x0000000802b2e4ce in ilLoadJpegL () from /opt/lib/libIL.so.1 #7 0x0000000802b54ca0 in ilLoadL () from /opt/lib/libIL.so.1 #8 0x0000000000685cd6 in CBitmap::Load (this=0x7fffffffdd38, filename=..., defaultAlpha=255 '\377') at /home/ports/games/spring/work/spring_98.0/rts/Rendering/Textures/Bitmap.cpp:294 #9 0x00000000009e1308 in agui::Picture::Load (this=0x1b6ab80, _file=...) at /home/ports/games/spring/work/spring_98.0/rts/aGui/Picture.cpp:31 0000010 0x00000000006b2e3a in SelectMenu::SelectMenu (this=0x1b43fb0, setup=...) at /home/ports/games/spring/work/spring_98.0/rts/Menu/SelectMenu.cpp:143 #11 0x000000000070c52b in SpringApp::Startup (this=<optimized out>) at /home/ports/games/spring/work/spring_98.0/rts/System/SpringApp.cpp:787 0000012 0x000000000070ae40 in SpringApp::Initialize (this=0x7fffffffe980) at /home/ports/games/spring/work/spring_98.0/rts/System/SpringApp.cpp:263 0000013 0x000000000070d701 in SpringApp::Run (this=0x0) at /home/ports/games/spring/work/spring_98.0/rts/System/SpringApp.cpp:862 0000014 0x00000000006e9556 in Run (argc=<optimized out>, argv=<optimized out>) at /home/ports/games/spring/work/spring_98.0/rts/System/Main.cpp:48 #15 0x00000000006e9a1b in main (argc=1, argv=0x7fffffffea68) at /home/ports/games/spring/work/spring_98.0/rts/System/Main.cpp:107 And here is the suicidal thread: (gdb) where #0 0x0000000805dc41aa in thr_kill () from /lib/libc.so.7 #1 0x0000000805dc4116 in raise () from /lib/libc.so.7 #2 0x0000000805dc28f9 in abort () from /lib/libc.so.7 0000003 0x00000008044430df in tcmalloc::Log(tcmalloc::LogMode, char const*, int, tcmalloc::LogItem, tcmalloc::LogItem, tcmalloc::LogItem, tcmalloc::LogItem) () from /opt/lib/libtcmalloc.so.4 0000004 0x0000000804440db7 in ?? () from /opt/lib/libtcmalloc.so.4 0000005 0x0000000804eecae8 in alGenAuxiliaryEffectSlots () from /opt/lib/libopenal.so.1 #6 0x00000000007976c1 in CEFX::CEFX (this=0x1b6a1c0, device=0x810006000) at /home/ports/games/spring/work/spring_98.0/rts/System/Sound/OpenAL/EFX.cpp:120 #7 0x00000000007a6dde in CSound::StartThread (this=0x1b3e540, maxSounds=<optimized out>) at /home/ports/games/spring/work/spring_98.0/rts/System/Sound/OpenAL/Sound.cpp:357 #8 0x00000000007aacbd in boost::_bi::bind_t<void, boost::_mfi::mf1<void, CSound, int>, boost::_bi::list2<boost::_bi::value<CSound*>, boost::_bi::value<int> > >::operator() (this=0x0) at /opt/include/boost/bind/bind_template.hpp:20 #9 0x00000008046964a5 in ?? () from /opt/lib/libboost_thread.so.1.55.0 0000010 0x0000000805a62775 in ?? () from /lib/libthr.so.3 #11 0x0000000000000000 in ?? () Backtrace stopped: Cannot access memory at address 0x7fffdfffe000 And the thread, that's writing something -- not much here: #0 0x0000000805dc534a in _write () from /lib/libc.so.7 #1 0x0000000805a651a6 in ?? () from /lib/libthr.so.3 #2 0x0000000804f2a704 in ?? () from /opt/lib/libopenal.so.1 0000003 0x0000000804f2c056 in ?? () from /opt/lib/libopenal.so.1 0000004 0x0000000805a62775 in ?? () from /lib/libthr.so.3 0000005 0x0000000000000000 in ?? () Backtrace stopped: Cannot access memory at address 0x7fffdfdfd000 > does it work when you set LoadingMT = 0 > maybe setting Sound = 0 makes it run? Where would I set these? Command-line? What's the syntax? > because of Using joystick 0: /dev/uhid0 shortly before crash There is no joystick here. Never used one in my life... > (thats all uncommon i saw) Disabling tcmalloc at build time produces a usable binary too... |
abma (administrator) 2015-04-24 22:14 |
are we talking about two different crashes? is sth. changed that you get the different stacktraces? now i'm a bit confused. all settings are set in springsettings.conf: https://springrts.com/wiki/Springsettings.cfg both stacktraces look like it crashes in external libs, so spring isn't to blame, the external lib is. please try the settings i wrote: Sound = 0 LoadingMT = 0 JoystickEnabled = 0 |
UnitedMarsupials (reporter) 2015-04-25 00:32 |
The crashes are from the same build -- only I used the non-stripped copy of the executable the second time. In both cases there are three threads at crash-time, one in _write(), one in thr_kill(), and one -- deep in libjpeg.so somewhere (though the exact location differs). Obviously, the runs are different -- but the build is the same. > both stacktraces look like it crashes in external libs, so spring isn't to > blame, the external lib is. The same libjpeg.so is used for nearly everything on this system -- including my entire KDE-desktop :-) |
abma (administrator) 2015-04-25 00:38 |
does your kde-desktop use tcmalloc? |
UnitedMarsupials (reporter) 2015-04-25 00:40 |
> does your kde-desktop use tcmalloc? No, it does not. But it was my impression, you are blaming libjpeg.so. I don't know, what you gain by using tcmalloc -- but thought to raise your awareness of it causing problems. At least some times... |
jK (developer) 2015-04-25 00:55 |
1. tcmalloc makes spring ~10% faster 2. seems your systemlibs have a problem with tcmalloc, not spring 3. i told you how to compile spring without it |
UnitedMarsupials (reporter) 2015-04-25 01:03 |
> 1. tcmalloc makes spring ~10% faster I wonder, if that would also be true compared to FreeBSD's malloc... Is there an easy way to benchmark? > 2. seems your systemlibs have a problem with tcmalloc, not spring Ok... > 3. i told you how to compile spring without it Not quite, but I figured it out... -DUSE_TCMALLOC:BOOL=false |
abma (administrator) 2015-04-26 11:00 |
it doesn't look like this could be fixed in spring, right? -> always disable usage of tcmalloc for freebsd? |
UnitedMarsupials (reporter) 2015-04-26 16:14 |
> it doesn't look like this could be fixed in spring, right? Depends on what the actual reason for the problem is. If, as I suspect, somehow the system malloc/free and the Google's implementation are mixed up in Spring's code (or in the way it calls out into libraries like jpeg), then it might be fixable. For example, could it be, that you aren't seeing the problem yourself because you build libjpeg and devil with tcmalloc too? > -> always disable usage of tcmalloc for freebsd? I'd suggest default use of tcmalloc to false at all times. Either way is fine, because the FreeBSD port of spring can always disable tcmalloc explicitly. |
jK (developer) 2015-04-26 19:22 |
> Depends on what the actual reason for the problem is. If, as I suspect, somehow the system malloc/free and the Google's implementation are mixed up in Spring's code (or in the way it calls out into libraries like jpeg), then it might be fixable. You can only override malloc() for the whole process. It's done via a LD_XYZ enviroment `hack`. Overriding it only for specific parts of a process/library would mean you have to explicit define custom allocator for all STLs and override malloc() & free() via nasty #defines etc. -> a lot very very nasty code -> not KISS So any sane coder uses the first approach (all or nothing). |
abma (administrator) 2015-05-01 18:27 |
Fix 9606b29eecbe0f837668928b36968e7e6e07b9f6 committed to develop branch: fix 0004754: default disable tcmalloc on freebsd, repo: spring changeset id: 4882 |
![]() |
|||
Date Modified | Username | Field | Change |
---|---|---|---|
2015-04-23 23:40 | UnitedMarsupials | New Issue | |
2015-04-24 01:18 | jK | Note Added: 0014379 | |
2015-04-24 07:43 | abma | Note Added: 0014380 | |
2015-04-24 07:43 | abma | Status | new => feedback |
2015-04-24 07:44 | abma | Relationship added | related to 0004755 |
2015-04-24 15:10 | UnitedMarsupials | Note Added: 0014381 | |
2015-04-24 15:10 | UnitedMarsupials | Status | feedback => new |
2015-04-24 16:49 | abma | Note Added: 0014382 | |
2015-04-24 16:49 | abma | Assigned To | => abma |
2015-04-24 16:49 | abma | Status | new => feedback |
2015-04-24 16:51 | abma | Note Edited: 0014382 | View Revisions |
2015-04-24 16:52 | abma | Note Edited: 0014382 | View Revisions |
2015-04-24 16:52 | abma | Note Edited: 0014382 | View Revisions |
2015-04-24 20:04 | UnitedMarsupials | Note Added: 0014385 | |
2015-04-24 20:04 | UnitedMarsupials | Status | feedback => assigned |
2015-04-24 22:14 | abma | Note Added: 0014386 | |
2015-04-25 00:32 | UnitedMarsupials | Note Added: 0014389 | |
2015-04-25 00:38 | abma | Note Added: 0014390 | |
2015-04-25 00:40 | UnitedMarsupials | Note Added: 0014391 | |
2015-04-25 00:53 | jK | Note View State: 0014391: private | |
2015-04-25 00:54 | jK | Note View State: 0014391: public | |
2015-04-25 00:55 | jK | Note Added: 0014393 | |
2015-04-25 01:03 | UnitedMarsupials | Note Added: 0014394 | |
2015-04-26 11:00 | abma | Note Added: 0014400 | |
2015-04-26 16:14 | UnitedMarsupials | Note Added: 0014401 | |
2015-04-26 19:22 | jK | Note Added: 0014402 | |
2015-05-01 18:27 | abma | Changeset attached | => spring develop 9606b29e |
2015-05-01 18:27 | abma | Note Added: 0014411 | |
2015-05-01 18:27 | abma | Status | assigned => resolved |
2015-05-01 18:27 | abma | Resolution | open => fixed |