0.7.0 beta bug: Wiping memory -- segmentation fault (core dumped)

Bug #451289 reported by Daniel Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
BleachBit
Fix Released
High
Andrew Ziem

Bug Description

Arch Linux, KDE 4.3.2, Kernel 2.6.31.4, Python 2.6.3
###

Ok this is going to be a bit more complicated. I hope I got enough information for you, if not please tell me what I have to do.
I have done everything as root because a normal user shouldn't have the rights to clean the memory, right?

First I got a error and nothing was done because of that:

### BEFORE:
# cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/swap partition 2498096 0 -1

# free
             total used free shared buffers cached
Mem: 2057056 1363148 693908 0 107156 632284
-/+ buffers/cache: 623708 1433348
Swap: 2498096 0 2498096

### CLICK PREVIEW
debug: clean_operation('system'), options = '['memory']'
debug: deepscans= {}
debug: searches= {}

### CLICK ON DELETE
debug: clean_operation('system'), options = '['memory']'
debug: disabling swap
debug: running cmd ['swapoff', '-a', '-v']
Traceback (most recent call last):
  File "/usr/share/bleachbit/Worker.py", line 91, in execute
    for ret in cmd.execute(self.really_delete):
  File "/usr/share/bleachbit/Command.py", line 103, in execute
    func_ret = self.func()
  File "/usr/share/bleachbit/Memory.py", line 198, in wipe_memory
    devices = disable_swap_linux()
  File "/usr/share/bleachbit/Memory.py", line 67, in disable_swap_linux
    % { 'args' : str(args), 'stdout' : stdout, 'stderr' : stderr } )
RuntimeError: Unexpected output:
args='['swapoff', '-a', '-v']'
stdout='swapoff on /dev/mapper/swap
'
stderr=''
debug: deepscans= {}
debug: searches= {}

But the swap device was "umounted" correctly:
#cat /proc/swaps
Filename Type Size Used Priority

So why the error?

####################################
When you do it a second time, or do a manually swapoff before this happens:

### CLICK PREVIEW
debug: clean_operation('system'), options = '['memory']'
debug: deepscans= {}
debug: searches= {}

### CLICK ON DELETE
debug: clean_operation('system'), options = '['memory']'
debug: deepscans= {}
debug: searches= {}

debug: clean_operation('system'), options = '['memory']'
debug: wipe_memory(), devices= None
debug: physical free: 1359511552 B (1296 MB)
info: allocating 1291535974 bytes of memory (1231.00 MB)
debug: wiping the memory I just allocated
[1] 6441 segmentation fault (core dumped) bleachbit

The return code I get after the segmentation fault is always 139:
# echo $?
139

After the crash my memory looks like this:

# free
             total used free shared buffers cached
Mem: 2057056 1345984 711072 0 107300 632260
-/+ buffers/cache: 606424 1450632
Swap: 0 0 0

#cat /proc/swaps
Filename Type Size Used Priority

I think it crashes when it tries to delete my ram, and with my swap is nothing done, right?
Because it goes very fast and I don't see or hear any hdd activity.

Regards

Tags: bug
Revision history for this message
Daniel Riedemann (darie) wrote :

Oh, and I see the following now in my post above:

debug: physical free: 1359511552 B (1296 MB)
info: allocating 1291535974 bytes of memory (1231.00 MB)

So there are 65 MB still free and not wiped. Is that intended?

Revision history for this message
Daniel Riedemann (darie) wrote :

I can't edit the bug report anymore -- I always get an error :-(
So just for clarification:

These three lines of output:
debug: clean_operation('system'), options = '['memory']'
debug: deepscans= {}
debug: searches= {}

Don't belong to "CLICK ON DELETE" I accidently copied them again. These are only part of "CLICK PREVIEW"

Regards

Revision history for this message
Andrew Ziem (ahziem1) wrote :

Thanks for the report

Issue #1: BleachBit expects the swap partition to look like /dev/sda5, so that explains the 'unexpected output'. That's easy to fix.

Issue#2: Segmentation fault. I've started on a way to mitigate this risk by using fork().

Issue#3: Only 95% is wiped. This is related to #3. I'm researching a way to get to 100% without a segmentation fault. In my tests going above 95% caused a seg fault, but apparently that does not work for you.

Changed in bleachbit:
assignee: nobody → Andrew Ziem (ahziem1)
milestone: none → 0.7.0
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Andrew Ziem (ahziem1) wrote :

#2 using fork() is in SVN revision 1304, so after a seg fault, BleachBit will at least re-mount swap (not on your system yet since it doesn't know about /dev/mapper/swap) and continue running.

Revision history for this message
Daniel Riedemann (darie) wrote :

Update: With revision 1311 the swapoff doesn't work, the fork dies with 139 - but swap gets correctly remounted afterwards.

Revision history for this message
Andrew Ziem (ahziem1) wrote :

I checked a plain installation of Arch Linux, and it uses /dev/sda2 for swap. Do you use LVM for swap? Could you run these commands?

cat /proc/partitions
pvscan
lvscan
vgscan

Changed in bleachbit:
status: Confirmed → In Progress
Revision history for this message
Andrew Ziem (ahziem1) wrote :

SVN 1340 fixes everything except ' /dev/mapper/swap'. Regarding comment #6, do you use LVM? Could you please reply with the output of these commands?

cat /proc/swaps
cat /proc/partitions
cat /etc/fstab

Revision history for this message
Andrew Ziem (ahziem1) wrote :

I discovered /dev/mapper/swap is common name on many Linux distro's for encrypted swap partition. Fixed in SVN 1354

Changed in bleachbit:
status: In Progress → Fix Committed
Revision history for this message
Daniel Riedemann (darie) wrote :

Hello Andrew,

I'm afraid to tell you that it doesn't work here :-(
Yes I have a fully encrypted hdd with lvm.

## First Click on "Delete"-button:

debug: clean_operation('system'), options = '['memory']'
debug: disabling swap
debug: running cmd ['swapoff', '-a', '-v']
Traceback (most recent call last):
  File "/usr/share/bleachbit/Worker.py", line 89, in execute
    for ret in cmd.execute(self.really_delete):
  File "/usr/share/bleachbit/Command.py", line 108, in execute
    for func_ret in self.func():
  File "/usr/share/bleachbit/Memory.py", line 241, in wipe_memory
    devices = disable_swap_linux()
  File "/usr/share/bleachbit/Memory.py", line 69, in disable_swap_linux
    % { 'args' : str(args), 'stdout' : stdout, 'stderr' : stderr } )
RuntimeError: Unexpected output:
args='['swapoff', '-a', '-v']'
stdout='swapoff für /dev/mapper/swap
'
stderr=''
debug: deepscans= {}
debug: searches= {}

But it get's umounted correctly !

## Second click on "Delete"-Button:
debug: clean_operation('system'), options = '['memory']'
debug: detected swap devices: None
debug: new nice value 19
Traceback (most recent call last):
  File "/usr/share/bleachbit/Memory.py", line 98, in fill_memory_linux
    login = os.getlogin()
OSError: [Errno 2] Datei oder Verzeichnis nicht gefunden
debug: physical free: 1498976256 B (1429 MB)
debug: wipe_memory() pid 6352 waiting for child pid 6386
info: allocating 1071.00 MB (1123946496 B) memory
debug: wiping 1071.00 MB I just allocated
warning: child process returned code 139
debug: re-enabling swap
debug: deepscans= {}
debug: searches= {}

re-enabling swap works. But the fork still dies with return code 139.

Maybe my many tmpfs mounts are the reason?
Please see my attachments for that.

Revision history for this message
Daniel Riedemann (darie) wrote :
Revision history for this message
Daniel Riedemann (darie) wrote :
Revision history for this message
Daniel Riedemann (darie) wrote :

Because I can't edit: I'm using svn revision 1369

Revision history for this message
Andrew Ziem (ahziem1) wrote :

BleachBit was confused on the German 'für'. Try SVN 1371. I also fixed the OSError 2.

Revision history for this message
Daniel Riedemann (darie) wrote :

Revision 1376:
First click on Delete I get: error: cannot find size of swap device '/dev/mapper/swap'

##Detailed output:
debug: clean_operation('system'), options = '['memory']'
debug: disabling swap
debug: running cmd ['swapoff', '-a', '-v']
debug: detected swap devices: ['/dev/mapper/swap']
info: wiping swap device '/dev/mapper/swap'
Traceback (most recent call last):
  File "/usr/share/bleachbit/Worker.py", line 89, in execute
    for ret in cmd.execute(self.really_delete):
  File "/usr/share/bleachbit/Command.py", line 108, in execute
    for func_ret in self.func():
  File "/usr/share/bleachbit/Memory.py", line 244, in wipe_memory
    wipe_swap_linux(devices)
  File "/usr/share/bleachbit/Memory.py", line 223, in wipe_swap_linux
    if get_swap_size_linux(device) > 8*1024**3:
  File "/usr/share/bleachbit/Memory.py", line 137, in get_swap_size_linux
    (device, open('/proc/partitions').read()))
RuntimeError: error: cannot find size of swap device '/dev/mapper/swap'
major minor #blocks name

   8 0 625131864 sda
   8 1 134217728 sda1
   8 2 128520 sda2
   8 3 2498107 sda3
   8 4 1 sda4
   8 5 64002928 sda5
   8 6 424280941 sda6
 254 0 64001900 dm-0
 254 1 424279913 dm-1
 254 2 2498107 dm-2

debug: deepscans= {}
debug: searches= {}

##Second click on Delete:
debug: clean_operation('system'), options = '['memory']'
debug: detected swap devices: None
debug: wipe_memory() pid 11021 waiting for child pid 11033
debug: new nice value 19
debug: dropping privileges of pid 11033 to uid 100
debug: physical free: 1320341504 B (1259 MB)
info: allocating 944.00 MB (990077952 B) memory
debug: wiping 944.00 MB I just allocated
warning: child process returned code 11
debug: re-enabling swap
debug: deepscans= {}
debug: searches= {}

Is return code 11 good or bad?
Do you try to get the swap size trough /proc/partitions? Wouldn't be /proc/swaps better and easier for that? (Because of LVM)

Revision history for this message
Andrew Ziem (ahziem1) wrote :

>Is return code 11 good or bad?

It means the forked process did not finish. Does /var/log/messages show the Linux 'out-of-memory killer' killed a process?

>Do you try to get the swap size trough /proc/partitions? Wouldn't be /proc/swaps better and easier for that? (Because of LVM)

Yes, try SVN 1382.

Changed in bleachbit:
status: Fix Committed → In Progress
Revision history for this message
Daniel Riedemann (darie) wrote :

Revision 1383:

Same again on first click:

debug: clean_operation('system'), options = '['memory']'
debug: disabling swap
debug: running cmd ['swapoff', '-a', '-v']
debug: detected swap devices: ['/dev/mapper/swap']
info: wiping swap device '/dev/mapper/swap'
Traceback (most recent call last):
  File "/usr/share/bleachbit/Worker.py", line 89, in execute
    for ret in cmd.execute(self.really_delete):
  File "/usr/share/bleachbit/Command.py", line 108, in execute
    for func_ret in self.func():
  File "/usr/share/bleachbit/Memory.py", line 246, in wipe_memory
    wipe_swap_linux(devices)
  File "/usr/share/bleachbit/Memory.py", line 225, in wipe_swap_linux
    if get_swap_size_linux(device) > 8*1024**3:
  File "/usr/share/bleachbit/Memory.py", line 139, in get_swap_size_linux
    (device, open('/proc/partitions').read()))
RuntimeError: error: cannot find size of swap device '/dev/mapper/swap'
major minor #blocks name

   8 0 625131864 sda
   8 1 134217728 sda1
   8 2 128520 sda2
   8 3 2498107 sda3
   8 4 1 sda4
   8 5 64002928 sda5
   8 6 424280941 sda6
 254 0 64001900 dm-0
 254 1 424279913 dm-1
 254 2 2498107 dm-2

debug: deepscans= {}
debug: searches= {}

##########

Same again for second click:

debug: clean_operation('system'), options = '['memory']'
debug: detected swap devices: None
debug: wipe_memory() pid 6301 waiting for child pid 6313
debug: new nice value 19
debug: dropping privileges of pid 6313 to uid 100
debug: physical free: 1402400768 B (1337 MB)
info: allocating 1002.00 MB (1051610112 B) memory
debug: wiping 1002.00 MB I just allocated
warning: child process returned code 11
debug: re-enabling swap
debug: deepscans= {}
debug: searches= {}

###########

dmesg after that shows:

python[6313]: segfault at 1c393010 ip 00007f6d6a02090b sp 00007fff30e1d398 error 6 in libc-2.10.1.so[7f6d69fa5000+149000]
Adding 2498096k swap on /dev/mapper/swap. Priority:-1 extents:1 across:2498096k

Ouch! :-(

Revision history for this message
Andrew Ziem (ahziem1) wrote :

> RuntimeError: error: cannot find size of swap device '/dev/mapper/swap'

OK. Try SVN 1385.

> python[6313]: segfault at 1c393010 ip 00007f6d6a02090b sp 00007fff30e1d398 error 6 in libc-2.10.1.so[7f6d69fa5000+149000]

Once the swap problems are fixed, please file another bug ticket for the 'segfault' and 'returned code 11' to be fixed after 0.7.0 is released.

Revision history for this message
Daniel Riedemann (darie) wrote :

Okay, no problem... :-) Do you mean one ticket for segfault and return code or do you mean one each (so two in total)?
And sorry that I have to say that, but I found another bug (I'm going to create the ticket now). I think this new one should be fixed before the final release of 0.7.0 ...

With Rev. 1385 it's exactly the same.
Just in case I overlooked something, here the output again:

debug: clean_operation('system'), options = '['memory']'
debug: disabling swap
debug: running cmd ['swapoff', '-a', '-v']
debug: detected swap devices: ['/dev/mapper/swap']
info: wiping swap device '/dev/mapper/swap'
Traceback (most recent call last):
  File "/usr/share/bleachbit/Worker.py", line 89, in execute
    for ret in cmd.execute(self.really_delete):
  File "/usr/share/bleachbit/Command.py", line 108, in execute
    for func_ret in self.func():
  File "/usr/share/bleachbit/Memory.py", line 246, in wipe_memory
    wipe_swap_linux(devices)
  File "/usr/share/bleachbit/Memory.py", line 225, in wipe_swap_linux
    if get_swap_size_linux(device) > 8*1024**3:
  File "/usr/share/bleachbit/Memory.py", line 139, in get_swap_size_linux
    (device, open('/proc/partitions').read()))
RuntimeError: error: cannot find size of swap device '/dev/mapper/swap'
major minor #blocks name

   8 0 625131864 sda
   8 1 134217728 sda1
   8 2 128520 sda2
   8 3 2498107 sda3
   8 4 1 sda4
   8 5 64002928 sda5
   8 6 424280941 sda6
 254 0 64001900 dm-0
 254 1 424279913 dm-1
 254 2 2498107 dm-2

debug: deepscans= {}
debug: searches= {}

Revision history for this message
Andrew Ziem (ahziem1) wrote :

That output doesn't look like SVN 1385. The biggest clue is '/proc/partitions' which was removed in SVN 1382

http://bleachbit.svn.sourceforge.net/viewvc/bleachbit/trunk/bleachbit/Memory.py?r1=1382&r2=1384

Also, I don't 'install' SVN at all, but your output shows it is running from /usr/.

Revision history for this message
Andrew Ziem (ahziem1) wrote :

>Okay, no problem... :-) Do you mean one ticket for segfault and return code or do you mean one each (so two in total)?

Sorry, I forgot to answer this question. I mean one new ticket for these two. They are related.

Revision history for this message
Daniel Riedemann (darie) wrote :

>That output doesn't look like SVN 1385.

Oups, sorry... I build a package but I forgot to install it. I think I should go earlier to bed to today... :-(
Now it works and looks like this:

debug: clean_operation('system'), options = '['memory']'
debug: disabling swap
debug: running cmd ['swapoff', '-a', '-v']
debug: detected swap devices: ['/dev/mapper/swap']
info: wiping swap device '/dev/mapper/swap'
debug: running cmd ['blkid', '/dev/mapper/swap', '-s', 'UUID']
debug: uuid(/dev/mapper/swap)='c6ea33e5-0af6-4148-8a92-b0d8eddfdf1f'
debug: reinitializing swap device /dev/mapper/swap
debug: running cmd ['mkswap', '/dev/mapper/swap', '-U', 'c6ea33e5-0af6-4148-8a92-b0d8eddfdf1f']
debug: wipe_memory() pid 15519 waiting for child pid 15528
debug: new nice value 19
debug: dropping privileges of pid 15528 to uid 100
debug: physical free: 1087000576 B (1036 MB)
info: allocating 777.00 MB (814930944 B) memory
debug: wiping 777.00 MB I just allocated
warning: child process returned code 11
debug: re-enabling swap
debug: deepscans= {}
debug: searches= {}

What does bleachbit do when it wipes the swap? It goes so fast and has so less hdd activity it can't be something like a dd if=/dev/zero ...

Revision history for this message
Andrew Ziem (ahziem1) wrote :

>What does bleachbit do when it wipes the swap? It goes so fast and has
> so less hdd activity it can't be something like a dd if=/dev/zero ...

Yes, basically the same as 'dd if=/dev/zero'

Changed in bleachbit:
status: In Progress → Fix Committed
Andrew Ziem (ahziem1)
Changed in bleachbit:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.