LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Tracking down "Segmentation fault" in blassic (https://www.linuxquestions.org/questions/slackware-14/tracking-down-segmentation-fault-in-blassic-4175522423/)

psionl0 10-17-2014 09:15 AM

Tracking down "Segmentation fault" in blassic
 
I have blassic installed on my 64-bit PC and 32-bit netbook.

On the PC it runs fine (using multilib) but on the netbook, every time I try to dimension a string array, it causes a segmentation fault and the terminal cursor disappears.

In an attempt to try and find out what is going wrong, I edited the blassic.SlackBuild script to stop it stripping down the symbols and then recreated and upgraded the new package.

When I ran gdb, this is what I got:
Code:

Reading symbols from /usr/bin/blassic...done.
(gdb) run
Starting program: /usr/bin/blassic
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?

Blassic 0.10.2
(C) 2001-2009 Julian Albo

Ok
dim a$(10)

Program received signal SIGSEGV, Segmentation fault.
0x0804e543 in __gnu_cxx::__exchange_and_add_dispatch(int*, int) [clone .constprop.317] ()
(gdb)

Where do I go from here?

the3dfxdude 10-17-2014 01:03 PM

Code:

bash-4.2$ gdb ./blassic
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 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 "i486-slackware-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/nnn/blassic/blassic-0.10.2/blassic...done.
(gdb) run
Starting program: /home/nnn/blassic/blassic-0.10.2/./blassic

Blassic 0.10.2
(C) 2001-2009 Julian Albo

Ok
dim a$(10)
Ok

Do you know more about how you compiled your program?

ntubski 10-17-2014 01:31 PM

Looking at the backtrace may be useful.

exchange_and_add sounds like a threading synchronization primitive to me.

psionl0 10-17-2014 07:36 PM

Quote:

Originally Posted by the3dfxdude (Post 5255185)
Do you know more about how you compiled your program?

I haven't (so far) done much more than run the SlackBuild script without the stripping instructions. On the netbook in question, since I installed 32-bit Slackware, I didn't have to worry about multi-lib. As I pointed out above, blassic runs fine on one computer and segfaults on another.

This is not the only package that gives inconsistent results like this and I want to get to the bottom of it. If I can figure out what the problem is for one package then I might be able to figure it out for the others. Blassic got the short straw so I am starting off with that package.

@ntubski, I will see what backtrace does and post the results here.

Drakeo 10-17-2014 11:56 PM

Quote:

On the PC it runs fine (using multilib)
this is a simple thing when you built it it compiled against a 32 bit library.
rename /usr/lib to /usr/lib~ and rebuild for 64 bit. and if your building for compat32 that is another road.
to look at. the reason it runs on multi-lib is when you built it it used some 32bit stuff and linked to it.

remeber to switch it back after building

psionl0 10-18-2014 02:08 AM

Quote:

Originally Posted by Drakeo (Post 5255420)
the reason it runs on multi-lib is when you built it it used some 32bit stuff and linked to it.

The reason it runs on the PC seems to be because I created the package while I was still on the LEET version of Slackware. The original blassic package was created on Aug 10 2012 and I upgraded the PC to 14.0 on 24 Dec 2012. When I got the netbook, I did a fresh install of 32 bit Slackware 14.0 and never had a prior version on it. I subsequently re-built the blassic package on the netbook.

When I created a symbol version of blassic for the PC, it too started seg-faulting. When I rebuilt the symbol-free version, it was also seg-faulting. However, when I upgrade to the original package, it runs fine.

@ntubski This is the backtrace I got on the netbook:
Code:

(gdb) run
Starting program: /usr/bin/blassic
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?

Blassic 0.10.2
(C) 2001-2009 Julian Albo

Ok
dim a$(10)

Program received signal SIGSEGV, Segmentation fault.
0x0804e543 in __gnu_cxx::__exchange_and_add_dispatch(int*, int) [clone .constprop.317] ()
(gdb) bt
#0  0x0804e543 in __gnu_cxx::__exchange_and_add_dispatch(int*, int) [clone .constprop.317] ()
#1  0x080b2cb0 in (anonymous namespace)::Array<std::string>::delref() [clone .isra.99] [clone .part.100] ()
#2  0x080b6344 in dimvarstring(std::string const&, Dimension const&) ()
#3  0x080a4b84 in RunnerLineImpl::do_DIM() ()
#4  0x0809af75 in RunnerLineImpl::execute() ()
#5  0x08089648 in Runner::runline(CodeLine const&) ()
#6  0x08089e98 in Runner::processline(std::string const&) ()
#7  0x0808dc3c in Runner::interactive() ()
#8  0x0804eb0f in main ()
(gdb)

And this is the backtrace I got on the PC:
Code:

(gdb) run
Starting program: /usr/bin/blassic-symb
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?

Blassic 0.10.2
(C) 2001-2009 Julian Albo

Ok
dim a$(10)

Program received signal SIGSEGV, Segmentation fault.
0x080bdfe0 in (anonymous namespace)::Array<std::string>::delref() [clone .isra.99] [clone .part.100] ()
(gdb) bt
#0  0x080bdfe0 in (anonymous namespace)::Array<std::string>::delref() [clone .isra.99] [clone .part.100] ()
#1  0x080c1b2d in dimvarstring(std::string const&, Dimension const&) ()
#2  0x080aeb14 in RunnerLineImpl::do_DIM() ()
#3  0x080a336e in RunnerLineImpl::execute_instruction() ()
#4  0x080a538c in RunnerLineImpl::execute() ()
#5  0x08091319 in Runner::runline(CodeLine const&) ()
#6  0x08091a10 in Runner::processline(std::string const&) ()
#7  0x080959d2 in Runner::interactive() ()
#8  0x0805021e in main ()
(gdb)

The two traces are not identical though I don't know why. In the PC version, execute() calls execute_instruction() which calls do_DIM(). However, in the netbook version execute() calls do_DIM directly.

The segfault in the PC version occurs at delref() in "anonymous namespace" (the linux-gate.so.1 bit) but in the netbook version, delref() manages to call __exchange_and_add_dispatch() before the segfault happens.

Now I'm stuck.

pan64 10-18-2014 02:09 AM

you may try ldd to check which libraries are in use....

psionl0 10-18-2014 02:25 AM

ldd on netbook:
Code:

$ ldd /usr/bin/blassic
        linux-gate.so.1 (0xffffe000)
        libSM.so.6 => /usr/lib/libSM.so.6 (0xb7782000)
        libICE.so.6 => /usr/lib/libICE.so.6 (0xb7769000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0xb7633000)
        libncurses.so.5 => /lib/libncurses.so.5 (0xb75f1000)
        libdl.so.2 => /lib/libdl.so.2 (0xb75eb000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7504000)
        libm.so.6 => /lib/libm.so.6 (0xb74d8000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0xb74bb000)
        libc.so.6 => /lib/libc.so.6 (0xb7336000)
        libuuid.so.1 => /lib/libuuid.so.1 (0xb7332000)
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb7310000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0xb730d000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb7307000)
        /lib/ld-linux.so.2 (0xb77a7000)

ldd on PC:
Code:

$ ldd /usr/bin/blassic-symb
        linux-gate.so.1 (0xffffe000)
        libSM.so.6 => /usr/lib/libSM.so.6 (0xf773c000)
        libICE.so.6 => /usr/lib/libICE.so.6 (0xf7725000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0xf7608000)
        libncurses.so.5 => /lib/libncurses.so.5 (0xf75c6000)
        libdl.so.2 => /lib/libdl.so.2 (0xf75c0000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xf74da000)
        libm.so.6 => /lib/libm.so.6 (0xf74ae000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0xf7494000)
        libc.so.6 => /lib/libc.so.6 (0xf730f000)
        libuuid.so.1 => /lib/libuuid.so.1 (0xf730b000)
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0xf72f2000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0xf72ef000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xf72ea000)
        /lib/ld-linux.so.2 (0xf776c000)

No difference that I can see.

moesasji 10-18-2014 02:50 AM

Quote:

Originally Posted by psionl0 (Post 5255063)
I have blassic installed on my 64-bit PC and 32-bit netbook.

Could you be a bit more specific on whether you indeed have multilib installed on the 64bit PC? Same question applies to the architecture of your netbook. Is that indeed x86?

This because the gdb output mentions linux-gate.so.1. This implies that it is compiled as a x86 32bit program, not a 64 bit one. See vDSO names listed in the man page.

So if you are rebuilding to get symbols on the 64 bit machine you have to make sure you indeed build in a 32 bit environment on that machine. Is that the case?

pan64 10-18-2014 02:52 AM

are those libraries really identical (use file and/or md5sum)

psionl0 10-18-2014 04:05 AM

Quote:

Originally Posted by moesasji (Post 5255461)
Could you be a bit more specific on whether you indeed have multilib installed on the 64bit PC? Same question applies to the architecture of your netbook. Is that indeed x86?

This because the gdb output mentions linux-gate.so.1. This implies that it is compiled as a x86 32bit program, not a 64 bit one. See vDSO names listed in the man page.

So if you are rebuilding to get symbols on the 64 bit machine you have to make sure you indeed build in a 32 bit environment on that machine. Is that the case?

Yes, my PC is 64-bit Slackware 14.0 with multilib installed. This means it has 32-bit AND 64-bit libraries. When I originally got blassic I had troubles running it as a 64-bit executable so, following the multi-lib instructions, I rebuilt it as a 32-bit executable.

I just compiled it as a 64-bit executable again but I still get seg-faults when I try to dimension a string array.

Quote:

Originally Posted by pan64 (Post 5255462)
are those libraries really identical (use file and/or md5sum)

They should be since they come from the same 32-bit Slackware 64 v14.0 distro but I will file/md5 them when I get time later tonight just to be sure.

moesasji 10-18-2014 05:51 AM

Seeing the combination of a segfault in a C++ section of the blassic code and gcc to compile I personally would start suspecting that the blassic code itself has "issues" with more recent versions of gcc. Simply because this would be the key thing that is different compared to when you compiled it in 2012 and there have been a lot of changes on the C++ front since then.

That something compiles on a newer compiler doesn't necessarily mean that it actually works as expected.

knudfl 10-18-2014 06:38 AM

`blassic-0.11.0' : Segmentation fault.

`blassic-0.10.2 : OK with ./configure --disable-svgalib

Code:

$ blassic

Blassic 0.10.2
(C) 2001-2009 Julian Albo

Ok

( The option --disable-svgalib : Ref. Fedora 19 blassic.spec ).

-

psionl0 10-18-2014 08:18 AM

Quote:

Originally Posted by knudfl (Post 5255522)
`blassic-0.10.2 : OK with ./configure --disable-svgalib

( The option --disable-svgalib : Ref. Fedora 19 blassic.spec ).
-

Unfortunately, neither ./configure --disable-svgalib nor ./configure --enable-svgalib had any effect on the segmentation fault which only appears when I try to dimension a string array.

The website https://build.opensuse.org/package/v...c/blassic.spec included some "sed"s which I tried too but to no avail.

Thanks for the suggestion though.

ntubski 10-18-2014 10:51 AM

Quote:

Originally Posted by psionl0 (Post 5255447)
@ntubski This is the backtrace I got on the netbook:

Looking at var.cpp lines 386-394, I think the segfault is happening in delete (where __gnu_cxx::__exchange_and_add_dispatch is used to lock the heap), which indicates heap corruption.

So the next thing to try is to run under valgrind, but compile with debug info so you can get line numbers.

the3dfxdude 10-18-2014 01:50 PM

BTW, I am running slackware 14.1 32-bit. So it's likely how you are compiling or other things influencing the segmentation fault. I'm not running a stock kernel here, so I'm not sure if there is some kind of kernel protection in play either. I do think the program is at fault here, and haven't taken the steps to run valgrind or other kinds of memory debugging to see if there is a corruption going on.

I also tried compiling 0.11, and I got syntax errors. Not a good sign.

metaschima 10-18-2014 03:22 PM

Tell the program devs about it, if you don't know the program internals it's hard for you to fix the bug.

psionl0 10-19-2014 12:54 AM

Quote:

Originally Posted by ntubski (Post 5255619)
So the next thing to try is to run under valgrind, but compile with debug info so you can get line numbers.

I set SLKCFLAGS="-g -O0 -fPIC" (which the SlackBuild uses to set CFLAGS and CXXFLAGS) which made blassic much more verbose about its breakdown.

This is a session running blassic alone.
Code:

Blassic 0.10.2
(C) 2001-2009 Julian Albo

Ok
dim a$(10)
*** glibc detected *** blassic: free(): invalid pointer: 0x00000000006feba0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7e4a6)[0x7f66c2fe94a6]
blassic[0x492ddd]
blassic[0x491e40]
blassic[0x49064f]
blassic[0x48f8a4]
blassic[0x479c5c]
blassic[0x4725e5]
blassic[0x472759]
blassic[0x45b29d]
blassic[0x45b950]
blassic[0x45c42a]
blassic[0x40cfcb]
blassic[0x40d1a0]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f66c2f8ca95]
blassic[0x409e59]
======= Memory map: ========
00400000-004e8000 r-xp 00000000 08:06 444293                            /usr/bin/blassic
006e7000-006ee000 rw-p 000e7000 08:06 444293                            /usr/bin/blassic
006ee000-006ff000 rw-p 00000000 00:00 0
00d27000-00d6c000 rw-p 00000000 00:00 0                                  [heap]
7f66c2742000-7f66c2747000 r-xp 00000000 08:06 436524                    /usr/lib64/libXdmcp.so.6.0.0
7f66c2747000-7f66c2946000 ---p 00005000 08:06 436524                    /usr/lib64/libXdmcp.so.6.0.0
7f66c2946000-7f66c2947000 rw-p 00004000 08:06 436524                    /usr/lib64/libXdmcp.so.6.0.0
7f66c2947000-7f66c2949000 r-xp 00000000 08:06 436242                    /usr/lib64/libXau.so.6.0.0
7f66c2949000-7f66c2b49000 ---p 00002000 08:06 436242                    /usr/lib64/libXau.so.6.0.0
7f66c2b49000-7f66c2b4a000 rw-p 00002000 08:06 436242                    /usr/lib64/libXau.so.6.0.0
7f66c2b4a000-7f66c2b67000 r-xp 00000000 08:06 437575                    /usr/lib64/libxcb.so.1.1.0
7f66c2b67000-7f66c2d67000 ---p 0001d000 08:06 437575                    /usr/lib64/libxcb.so.1.1.0
7f66c2d67000-7f66c2d68000 rw-p 0001d000 08:06 437575                    /usr/lib64/libxcb.so.1.1.0
7f66c2d68000-7f66c2d6b000 r-xp 00000000 08:06 1177605                    /lib64/libuuid.so.1.3.0
7f66c2d6b000-7f66c2f6a000 ---p 00003000 08:06 1177605                    /lib64/libuuid.so.1.3.0
7f66c2f6a000-7f66c2f6b000 rw-p 00002000 08:06 1177605                    /lib64/libuuid.so.1.3.0
7f66c2f6b000-7f66c3120000 r-xp 00000000 08:06 1183700                    /lib64/libc-2.15.so
7f66c3120000-7f66c3320000 ---p 001b5000 08:06 1183700                    /lib64/libc-2.15.so
7f66c3320000-7f66c3324000 r--p 001b5000 08:06 1183700                    /lib64/libc-2.15.so
7f66c3324000-7f66c3326000 rw-p 001b9000 08:06 1183700                    /lib64/libc-2.15.so
7f66c3326000-7f66c332b000 rw-p 00000000 00:00 0
7f66c332b000-7f66c3340000 r-xp 00000000 08:06 398684                    /usr/lib64/libgcc_s.so.1
7f66c3340000-7f66c353f000 ---p 00015000 08:06 398684                    /usr/lib64/libgcc_s.so.1
7f66c353f000-7f66c3540000 rw-p 00014000 08:06 398684                    /usr/lib64/libgcc_s.so.1
7f66c3540000-7f66c363a000 r-xp 00000000 08:06 1178650                    /lib64/libm-2.15.so
7f66c363a000-7f66c3839000 ---p 000fa000 08:06 1178650                    /lib64/libm-2.15.so
7f66c3839000-7f66c383a000 r--p 000f9000 08:06 1178650                    /lib64/libm-2.15.so
7f66c383a000-7f66c383b000 rw-p 000fa000 08:06 1178650                    /lib64/libm-2.15.so
7f66c383b000-7f66c391e000 r-xp 00000000 08:06 430808                    /usr/lib64/libstdc++.so.6.0.17
7f66c391e000-7f66c3b1d000 ---p 000e3000 08:06 430808                    /usr/lib64/libstdc++.so.6.0.17
7f66c3b1d000-7f66c3b25000 r--p 000e2000 08:06 430808                    /usr/lib64/libstdc++.so.6.0.17
7f66c3b25000-7f66c3b27000 rw-p 000ea000 08:06 430808                    /usr/lib64/libstdc++.so.6.0.17
7f66c3b27000-7f66c3b3c000 rw-p 00000000 00:00 0
7f66c3b3c000-7f66c3b3f000 r-xp 00000000 08:06 1183701                    /lib64/libdl-2.15.so
7f66c3b3f000-7f66c3d3e000 ---p 00003000 08:06 1183701                    /lib64/libdl-2.15.so
7f66c3d3e000-7f66c3d3f000 r--p 00002000 08:06 1183701                    /lib64/libdl-2.15.so
7f66c3d3f000-7f66c3d40000 rw-p 00003000 08:06 1183701                    /lib64/libdl-2.15.so
7f66c3d40000-7f66c3d8c000 r-xp 00000000 08:06 1177359                    /lib64/libncurses.so.5.9
7f66c3d8c000-7f66c3f8c000 ---p 0004c000 08:06 1177359                    /lib64/libncurses.so.5.9
7f66c3f8c000-7f66c3f91000 rw-p 0004c000 08:06 1177359                    /lib64/libncurses.so.5.9
7f66c3f91000-7f66c40c3000 r-xp 00000000 08:06 436200                    /usr/lib64/libX11.so.6.3.0
7f66c40c3000-7f66c42c3000 ---p 00132000 08:06 436200                    /usr/lib64/libX11.so.6.3.0
7f66c42c3000-7f66c42c9000 rw-p 00132000 08:06 436200                    /usr/lib64/libX11.so.6.3.0
7f66c42c9000-7f66c42df000 r-xp 00000000 08:06 435204                    /usr/lib64/libICE.so.6.3.0
7f66c42df000-7f66c44df000 ---p 00016000 08:06 435204                    /usr/lib64/libICE.so.6.3.0
7f66c44df000-7f66c44e0000 rw-p 00016000 08:06 435204                    /usr/lib64/libICE.so.6.3.0
7f66c44e0000-7f66c44e4000 rw-p 00000000 00:00 0
7f66c44e4000-7f66c44eb000 r-xp 00000000 08:06 435211                    /usr/lib64/libSM.so.6.0.1
7f66c44eb000-7f66c46ea000 ---p 00007000 08:06 435211                    /usr/lib64/libSM.so.6.0.1
7f66c46ea000-7f66c46eb000 rw-p 00006000 08:06 435211                    /usr/lib64/libSM.so.6.0.1
7f66c46eb000-7f66c470e000 r-xp 00000000 08:06 1183747                    /lib64/ld-2.15.so
7f66c48dc000-7f66c48e4000 rw-p 00000000 00:00 0
7f66c490b000-7f66c490d000 rw-p 00000000 00:00 0
7f66c490d000-7f66c490e000 r--p 00022000 08:06 1183747                    /lib64/ld-2.15.so
7f66c490e000-7f66c4910000 rw-p 00023000 08:06 1183747                    /lib64/ld-2.15.so
7fffc2c5c000-7fffc2c7d000 rw-p 00000000 00:00 0                          [stack]
7fffc2d13000-7fffc2d14000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted

and this is a session using valgrind:
Code:

$ valgrind --leak-check=yes blassic
==2694== Memcheck, a memory error detector
==2694== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==2694== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==2694== Command: blassic
==2694==
==2694== Syscall param rt_sigaction(act->sa_mask) points to uninitialised byte(s)
==2694==    at 0x6228BA5: __libc_sigaction (in /lib64/libc-2.15.so)
==2694==    by 0x40A10F: (anonymous namespace)::init_signal_handlers() (blassic.cpp:171)
==2694==    by 0x40C970: (anonymous namespace)::blassic_main(int, char**) (blassic.cpp:707)
==2694==    by 0x40D19F: main (blassic.cpp:911)
==2694==  Address 0x7fefff978 is on thread 1's stack
==2694==
==2694== Syscall param rt_sigaction(act->sa_mask) points to uninitialised byte(s)
==2694==    at 0x6228BA5: __libc_sigaction (in /lib64/libc-2.15.so)
==2694==    by 0x40A16B: (anonymous namespace)::init_signal_handlers() (blassic.cpp:184)
==2694==    by 0x40C970: (anonymous namespace)::blassic_main(int, char**) (blassic.cpp:707)
==2694==    by 0x40D19F: main (blassic.cpp:911)
==2694==  Address 0x7fefff978 is on thread 1's stack
==2694==

Blassic 0.10.2
(C) 2001-2009 Julian Albo

Ok
dim c(20)
Ok
dim a$(14)
==2694== Conditional jump or move depends on uninitialised value(s)
==2694==    at 0x492D8D: (anonymous namespace)::Array<std::string>::delref() (var.cpp:453)
==2694==    by 0x491E3F: (anonymous namespace)::Array<std::string>::operator=((anonymous namespace)::Array<std::string> const&) (var.cpp:433)
==2694==    by 0x49064E: void (anonymous namespace)::dimvar<std::string>(std::string const&, Dimension const&) (var.cpp:512)
==2694==    by 0x48F8A3: dimvarstring(std::string const&, Dimension const&) (var.cpp:593)
==2694==    by 0x479C5B: RunnerLineImpl::do_DIM() (runnerline_instructions.cpp:1529)
==2694==    by 0x4725E4: RunnerLineImpl::execute_instruction() (runnerline_impl.cpp:4016)
==2694==    by 0x472758: RunnerLineImpl::execute() (runnerline_impl.cpp:4284)
==2694==    by 0x45B29C: Runner::runline(CodeLine const&) (runner.cpp:1905)
==2694==    by 0x45B94F: Runner::processline(std::string const&) (runner.cpp:2009)
==2694==    by 0x45C429: Runner::interactive() (runner.cpp:2139)
==2694==    by 0x40CFCA: (anonymous namespace)::blassic_main(int, char**) (blassic.cpp:873)
==2694==    by 0x40D19F: main (blassic.cpp:911)
==2694==
==2694== Use of uninitialised value of size 8
==2694==    at 0x492DA3: (anonymous namespace)::Array<std::string>::delref() (var.cpp:453)
==2694==    by 0x491E3F: (anonymous namespace)::Array<std::string>::operator=((anonymous namespace)::Array<std::string> const&) (var.cpp:433)
==2694==    by 0x49064E: void (anonymous namespace)::dimvar<std::string>(std::string const&, Dimension const&) (var.cpp:512)
==2694==    by 0x48F8A3: dimvarstring(std::string const&, Dimension const&) (var.cpp:593)
==2694==    by 0x479C5B: RunnerLineImpl::do_DIM() (runnerline_instructions.cpp:1529)
==2694==    by 0x4725E4: RunnerLineImpl::execute_instruction() (runnerline_impl.cpp:4016)
==2694==    by 0x472758: RunnerLineImpl::execute() (runnerline_impl.cpp:4284)
==2694==    by 0x45B29C: Runner::runline(CodeLine const&) (runner.cpp:1905)
==2694==    by 0x45B94F: Runner::processline(std::string const&) (runner.cpp:2009)
==2694==    by 0x45C429: Runner::interactive() (runner.cpp:2139)
==2694==    by 0x40CFCA: (anonymous namespace)::blassic_main(int, char**) (blassic.cpp:873)
==2694==    by 0x40D19F: main (blassic.cpp:911)
==2694==
==2694== Conditional jump or move depends on uninitialised value(s)
==2694==    at 0x492DB9: (anonymous namespace)::Array<std::string>::delref() (var.cpp:453)
==2694==    by 0x491E3F: (anonymous namespace)::Array<std::string>::operator=((anonymous namespace)::Array<std::string> const&) (var.cpp:433)
==2694==    by 0x49064E: void (anonymous namespace)::dimvar<std::string>(std::string const&, Dimension const&) (var.cpp:512)
==2694==    by 0x48F8A3: dimvarstring(std::string const&, Dimension const&) (var.cpp:593)
==2694==    by 0x479C5B: RunnerLineImpl::do_DIM() (runnerline_instructions.cpp:1529)
==2694==    by 0x4725E4: RunnerLineImpl::execute_instruction() (runnerline_impl.cpp:4016)
==2694==    by 0x472758: RunnerLineImpl::execute() (runnerline_impl.cpp:4284)
==2694==    by 0x45B29C: Runner::runline(CodeLine const&) (runner.cpp:1905)
==2694==    by 0x45B94F: Runner::processline(std::string const&) (runner.cpp:2009)
==2694==    by 0x45C429: Runner::interactive() (runner.cpp:2139)
==2694==    by 0x40CFCA: (anonymous namespace)::blassic_main(int, char**) (blassic.cpp:873)
==2694==    by 0x40D19F: main (blassic.cpp:911)
==2694==
==2694== Conditional jump or move depends on uninitialised value(s)
==2694==    at 0x4C29F52: operator delete[](void*) (vg_replace_malloc.c:515)
==2694==    by 0x492DDC: (anonymous namespace)::Array<std::string>::delref() (var.cpp:453)
==2694==    by 0x491E3F: (anonymous namespace)::Array<std::string>::operator=((anonymous namespace)::Array<std::string> const&) (var.cpp:433)
==2694==    by 0x49064E: void (anonymous namespace)::dimvar<std::string>(std::string const&, Dimension const&) (var.cpp:512)
==2694==    by 0x48F8A3: dimvarstring(std::string const&, Dimension const&) (var.cpp:593)
==2694==    by 0x479C5B: RunnerLineImpl::do_DIM() (runnerline_instructions.cpp:1529)
==2694==    by 0x4725E4: RunnerLineImpl::execute_instruction() (runnerline_impl.cpp:4016)
==2694==    by 0x472758: RunnerLineImpl::execute() (runnerline_impl.cpp:4284)
==2694==    by 0x45B29C: Runner::runline(CodeLine const&) (runner.cpp:1905)
==2694==    by 0x45B94F: Runner::processline(std::string const&) (runner.cpp:2009)
==2694==    by 0x45C429: Runner::interactive() (runner.cpp:2139)
==2694==    by 0x40CFCA: (anonymous namespace)::blassic_main(int, char**) (blassic.cpp:873)
==2694==
==2694== Invalid free() / delete / delete[] / realloc()
==2694==    at 0x4C29F9C: operator delete[](void*) (vg_replace_malloc.c:515)
==2694==    by 0x492DDC: (anonymous namespace)::Array<std::string>::delref() (var.cpp:453)
==2694==    by 0x491E3F: (anonymous namespace)::Array<std::string>::operator=((anonymous namespace)::Array<std::string> const&) (var.cpp:433)
==2694==    by 0x49064E: void (anonymous namespace)::dimvar<std::string>(std::string const&, Dimension const&) (var.cpp:512)
==2694==    by 0x48F8A3: dimvarstring(std::string const&, Dimension const&) (var.cpp:593)
==2694==    by 0x479C5B: RunnerLineImpl::do_DIM() (runnerline_instructions.cpp:1529)
==2694==    by 0x4725E4: RunnerLineImpl::execute_instruction() (runnerline_impl.cpp:4016)
==2694==    by 0x472758: RunnerLineImpl::execute() (runnerline_impl.cpp:4284)
==2694==    by 0x45B29C: Runner::runline(CodeLine const&) (runner.cpp:1905)
==2694==    by 0x45B94F: Runner::processline(std::string const&) (runner.cpp:2009)
==2694==    by 0x45C429: Runner::interactive() (runner.cpp:2139)
==2694==    by 0x40CFCA: (anonymous namespace)::blassic_main(int, char**) (blassic.cpp:873)
==2694==  Address 0x6feba0 is 0 bytes inside data symbol "_ZN12_GLOBAL__N_114arrayvarstringE"
==2694==
Ok

Near as I can tell, an uninitialized pointer is the culprit but I'm not sure what to do about it.

pan64 10-19-2014 04:12 AM

you can try to set a breakpoint and go into it - or try to link statically...

psionl0 10-19-2014 06:39 AM

Quote:

Originally Posted by pan64 (Post 5255909)
you can try to set a breakpoint and go into it - or try to link statically...

I already have a breakpoint right where I need it (at the point of segfault) and more information than I can process so far.

Even if static linking masked the problem for blassic, it doesn't help me in the long run. I have a lot of packages with segfaulting problems (even the esteemed Alien's vlc). In fact, it's almost a coin toss whether a package I install will actually run or scream "segfault" and die. There can't be that many poorly put together packages. There must be a problem with my Slackware setup which is why I must continue along this path.

That said, I find it amazing that a simple basic interpreter would need over 40 source files each thousands of lines long and during execution would have to link up with over 15 dynamic libraries. And in spite of the code verbosity, it can't handle a simple heap violation.

55020 10-19-2014 08:46 AM

Quote:

Originally Posted by psionl0 (Post 5255968)
I have a lot of packages with segfaulting problems (even the esteemed Alien's vlc). In fact, it's almost a coin toss whether a package I install will actually run or scream "segfault" and die. There can't be that many poorly put together packages. There must be a problem with my Slackware setup which is why I must continue along this path.

Well, that's a different problem, and this path is not necessarily the best path for that problem.

If you have lots of segfaults, there are probably several different causes. There certainly are a *lot* of poorly put together packages. In the case of vlc, it isn't fair for me to imply it might be poorly put together: no, it's a major achivement that it works at all, considering that it has to rely on so many poorly put together dependencies and rotten APIs.

But whilst the in-depth approach you've taken with blassic is good for finding problems in blassic, it's not really the best way of finding and solving a more general problem. For one thing, don't start with blassic: C is much simpler to debug than C++. For another, you only need to find out whether the stack dumps of the various failing programs have a common theme (what were they trying to do when they crashed). And most of all, it's just easier to manage your Slackware installation properly. No little experiments outside a VM, no mix-and-match between -stable and -current, the absolute minimum of multilib, and, dare I say, no rebuilds of standard packages with debugging symbols outside a VM. I apologise if you haven't done anything like that. But it will be more effective to eliminate this potential problem by performing an audit of your system against a Slackware install dvd.

The reason for this is that incompatibilities in dynamic linked libraries will often cause segfaults. You can make this happen by using a different .so file to the one that the program was built against. This is why the often-repeated advice to "just create the missing symlink" is *TERRIBLE* advice. As a different example, the gdal library can optionally be built with a patched internal version of libjpeg to support 12-bit jpegs -- this mostly works, but it makes qgis (which depends on gdal) segfault in one or two very specific places.

Or it might be hardware...

ntubski 10-19-2014 09:26 AM

Quote:

Originally Posted by psionl0 (Post 5255871)
I set SLKCFLAGS="-g -O0 -fPIC" (which the SlackBuild uses to set CFLAGS and CXXFLAGS) which made blassic much more verbose about its breakdown.

That's just glibc trying to helpful. As far as I know, you can ignore everything after the line "invalid pointer" part; we already have a backtrace with line numbers, and we're not going to learn much from the memory map.

Quote:

and this is a session using valgrind:
Code:

$ valgrind --leak-check=yes blassic
...
==2694== Syscall param rt_sigaction(act->sa_mask) points to uninitialised byte(s)
==2694==    at 0x6228BA5: __libc_sigaction (in /lib64/libc-2.15.so)
==2694==    by 0x40A10F: (anonymous namespace)::init_signal_handlers() (blassic.cpp:171)
...


This is a bug though probably harmless. You can fix it by adding sigfillset(&act.sa_mask); before the call to sigaction.

Code:

...
dim a$(14)
==2694== Conditional jump or move depends on uninitialised value(s)
==2694==    at 0x492D8D: (anonymous namespace)::Array<std::string>::delref() (var.cpp:453)
==2694==    by 0x491E3F: (anonymous namespace)::Array<std::string>::operator=((anonymous namespace)::Array<std::string> const&) (var.cpp:433)
==2694==    by 0x49064E: void (anonymous namespace)::dimvar<std::string>(std::string const&, Dimension const&) (var.cpp:512)
==2694==    by 0x48F8A3: dimvarstring(std::string const&, Dimension const&) (var.cpp:593)
...
==2694== Use of uninitialised value of size 8
...
==2694== Invalid free() / delete / delete[] / realloc()
==2694==    at 0x4C29F9C: operator delete[](void*) (vg_replace_malloc.c:515)
==2694==    by 0x492DDC: (anonymous namespace)::Array<std::string>::delref() (var.cpp:453)
...
==2694==  Address 0x6feba0 is 0 bytes inside data symbol "_ZN12_GLOBAL__N_114arrayvarstringE"
==2694==
Ok


So apparently arrayvarstring["a$"].value is uninitialized. It looks like all Array<C> constructors do initialize it, so I'm not sure how that could be. Is it possible some versions of C++ runtime libraries don't like the 0 length array (new C [0])? It is legal C++ though.

Quote:

I already have a breakpoint right where I need it (at the point of segfault) and more information than I can process so far.
You probably want to break a little earlier: in every Array<C> constructor step through to check whether value gets initialized.

Quote:

Originally Posted by 55020
Or it might be hardware...

It was mentioned the crashes happen on at least 2 boxes, so it's pretty unlikely to be hardware.

psionl0 10-19-2014 11:46 AM

Quote:

Originally Posted by 55020 (Post 5256009)
And most of all, it's just easier to manage your Slackware installation properly. No little experiments outside a VM, no mix-and-match between -stable and -current, the absolute minimum of multilib, and, dare I say, no rebuilds of standard packages with debugging symbols outside a VM. I apologise if you haven't done anything like that.

I can assure you that mine is a vanilla Slackware installation (with multilib).

I can't guarantee that some obscure package I installed hasn't slipped in a rogue substitute library somewhere but md5ing all of my libraries will take some time. Of course, this is rendered unlikely since both 32-bit and 64-bit compilations of blassic have the same segfault problem - meaning that both 64-bit library and its equivalent 32-bit library would have had to be changed the same way.

If it helps, some of the segfaulting packages (like vlc) still run under gdb. In fact, the run instruction for my vlc is echo run | gdb vlc.

moesasji 10-19-2014 12:07 PM

Quote:

Originally Posted by psionl0 (Post 5256084)
If it helps, some of the segfaulting packages (like vlc) still run under gdb. In fact, the run instruction for my vlc is echo run | gdb vlc.

Slightly off-topic, but just in case you aren't aware:

If you experience segfaulting packages that run fine for others you should check that your hardware is fine by running memtest86+ for an extended period. This is simply one of the first thing to do if strange segfaults and/or compilation-errors pop up on a system. If your system doesn't run this test without errors you are sure to have a hardware problem. The slackware install DVD has the memtest option available when you boot from it.

btw) Keep in mind that completing the memtest run without errors doesn't actually guarantee that the hardware is fine. I've seen memory errors pop up only when a system is pushed harder, ie during compilation when the voltage lines might drop.

psionl0 10-21-2014 12:20 AM

Quote:

Originally Posted by moesasji (Post 5256089)
If you experience segfaulting packages that run fine for others you should check that your hardware is fine by running memtest86+ for an extended period.

Blassic throws exactly the same problems when I run it outside of X. This is definitely no memory glitch.

It is taking me longer than expected to learn how to set a break point at line 401 in var.cpp (either in gdb, valgrind or both) so if it takes me a while before I can provide more info don't think I have given up on this task.

metaschima 10-21-2014 10:24 AM

I'm thinking blassic is no longer maintained. Their main site is down and distros ship with patched versions in order for it to even build. How about FreeBasic or some other FLOSS basic compiler or interpreter ?

psionl0 10-21-2014 12:01 PM

I only keep blassic around for those rare occasions when I get a little maudlin since it is closest to the basics I grew up with (like Commodore 64 basic or GWbasic). For any remotely serious programming, I would of course use Java, C or C++ (or even fpc).

As explained before, my main reason for trying to fix this is to gain some experience at fixing other rogue programs (although admittedly, vlc with all its dependencies might be beyond my abilities). Since blassic used to work before the latest Slackware upgrade, it is possible that one or more libraries doesn't operate the same way that blassic expects it to anymore. If I give up now, I will never know.

metaschima 10-21-2014 12:17 PM

Quote:

Originally Posted by psionl0 (Post 5257212)
As explained before, my main reason for trying to fix this is to gain some experience at fixing other rogue programs (although admittedly, vlc with all its dependencies might be beyond my abilities). Since blassic used to work before the latest Slackware upgrade, it is possible that one or more libraries doesn't operate the same way that blassic expects it to anymore. If I give up now, I will never know.

Check out the patches that the other distros push, maybe they found the bug. You could also try upgrading Slackware package-wise and try to isolate the package change that caused it.

mancha 10-21-2014 05:37 PM

Quote:

Originally Posted by psionl0 (Post 5257212)
As explained before, my main reason for trying to fix this is to gain some experience at fixing other rogue programs...Since blassic used to work before the latest Slackware upgrade, it is possible that one or more libraries doesn't operate the same way that blassic expects it to anymore.

Has anyone else been able to reproduce your issue? the3dfxdude in post #2 can't reproduce and I just built blassic 0.10.2 from SBo on both
Slackware 14.1 x86 and x86_64 and can't reproduce either.

Before we go around calling blassic and vlc rogue, let's make sure the problem isn't something particular to your configuration. You're not
being very precise in your reports. What Slackware version are you using? When you say "the latest Slackware upgrade", which do mean?

--mancha

psionl0 10-21-2014 11:05 PM

Quote:

Originally Posted by mancha (Post 5257376)
Before we go around calling blassic and vlc rogue, let's make sure the problem isn't something particular to your configuration. You're not
being very precise in your reports. What Slackware version are you using? When you say "the latest Slackware upgrade", which do mean?

As my profile shows, I am running Slackware 14.0 (I chickened out of upgrading to 14.1) and I have installed the blassic-0.10.2 package which I got from SlackBuilds.org (blassic 0.11 was never finished to a stable version).

Although my Slackware installation is pretty much vanilla, I suspect a problem with how it is setup but so far I have no way of knowing whether the problem is with my Slackware setup or with blassic itself. All I know is that when I built the package under Slackware 13.37 there were apparently no problems (even when running the package under 14.0) but after compiling under Slackware 14.0 I get segfaults.

psionl0 10-23-2014 12:38 PM

Update
 
My SO also has a laptop with Slackware 14.0 installed on it. So I built and ran blassic on that laptop and got the same segmentation fault.

I then remembered an old laptop that still has Slackware 33.7 (32 bits) on it. Compiling blassic on that laptop produced a program that ran without errors on the laptop, the netbook and the PC.

It seems that the problem lies with Slackware 14.0 - probably gcc. When I installed multilib, I had to upgrade the gcc packages to their multilib versions as per the multilib instructions. This is the list of gcc packages currently installed:
Code:

~$ ls /var/log/packages | grep gcc
gcc-4.7.1_multilib-x86_64-1alien
gcc-g++-4.7.1_multilib-x86_64-1alien
gcc-gfortran-4.7.1_multilib-x86_64-1alien
gcc-gnat-4.7.1_multilib-x86_64-1alien
gcc-go-4.7.1_multilib-x86_64-1alien
gcc-java-4.7.1_multilib-x86_64-1alien
gcc-objc-4.7.1_multilib-x86_64-1alien
gccmakedep-1.0.2-noarch-2

So I'm not sure if the problem lies with the native gcc packages or exclusively with the multilib versions.


All times are GMT -5. The time now is 07:56 AM.