[Gambas-user] [CRASH REPORT] gbUDisk2

Tony Morehen tmorehen at ...3602...
Mon Aug 7 19:31:54 CEST 2017


#8173 seems to have fixed everything, including a crash when I enable 
dbus signalling, which I haven't brought up yet.  Now I have to figure 
out how to install 8173 to all my PCs

Some advice please.  Currently, I have many calls like 
DBus["system://org.freedesktop.UDisks2"]["/org/freedesktop/UDisks2/block_devices/sda1", 
"org.freedesktop.UDisks2.Filesystem"].MountPoints. (status quo)

I can replace it with new approach 1:
Private $DBusApp As DBusApplication = New DBusApplication(MyDBus.System, 
$Application)

mnt=$DBusApp["/org/freedesktop/UDisks2/block_devices/sda1", 
"org.freedesktop.UDisks2.Filesystem"].MountPoints

or even new approach 2:

Private Proxy as DBusProxy

Proxy = $DBusApp["/org/freedesktop/UDisks2/block_devices/sda1", 
"org.freedesktop.UDisks2.Filesystem"]

mnt=Proxy.Mountpoints

What would be your preferred approach? I know that the DBus class caches 
DBus Applications so that there doesn't seem to be any resource 
advantages to new approach 1.  New approach 2 will require 2 proxies for 
each drive, one for the Filesystem interface and one for the Block 
interface.

On 2017-08-07 09:52 AM, Benoît Minisini wrote:
> Le 07/08/2017 à 15:02, Adrien Prokopowicz a écrit :
>> Le Sun, 06 Aug 2017 17:56:27 +0200, Tony Morehen 
>> <tmorehen at ...3602...> a écrit:
>>
>>> Hello all,
>>>
>>> Damn, my program crashed Gambas this way :
>>>
>>> 1) Run the program
>>> 2) Plug in a usb drive
>>> 3) Click the mount button, mounts OK
>>> 4) Click the unmount button
>>> Program crashes Aborted(6)
>>> Console shows realloc error invalid old size
>>>
>>> Background:
>>> I'm writing a Udisks2 module that communicates with UDisks2 over dbus.
>>> It gathers drive info on existing drives and receives notifications 
>>> when
>>> a new drive is plugged in, usb stick etc.
>>> Two problems:
>>> 1) The crash above.  Note that unmount works if the usb drive is 
>>> already
>>> plugged in.  Careful: the program defaults to unmounting /dev/sdb1.
>>> Make sure you use the right drive id.
>>> 2) The program intially sends some basic drive info to debug output.
>>> First, it prints the info item by item with no problems. Then it tries
>>> to print the same items in one print statement.  Some of the output is
>>> garbage.  What's worst, I've tried saving each info item to separate
>>> variables.  If I step through the assignments one item at a time, the
>>> individual assignment is at first correct. However, after the next item
>>> is assigned, the previous item's value also changes.  This looks like a
>>> buffer overrun or a stack overflow.
>>
>> After a bit of searching, I found that the offending code can be 
>> reduced to
>> this single line :
>>
>> Print 
>> DBus["system://org.freedesktop.UDisks2"]["/org/freedesktop/UDisks2/block_devices/sda1", 
>> "org.freedesktop.UDisks2.Filesystem"].MountPoints
>>
>> It appears this property gets translated to a Byte[][], but the 
>> interpreter crashes
>> when trying to create one from the native components, because the 
>> class's symbol table
>> is not initialized yet (as object classes are created dynamically).
>>
>> However, creating one from Gambas code works, and in fact, creating 
>> one before
>> the D-Bus call makes it not crash anymore :
>>
>>    Dim x As New Byte[][]
>>    Print 
>> DBus["system://org.freedesktop.UDisks2"]["/org/freedesktop/UDisks2/block_devices/sda1", 
>> "org.freedesktop.UDisks2.Filesystem"].MountPoints 'works!
>>
>> Now you have a workaround, for until this is actually fixed. :)
>>
>> Regards,
>
> Is it better with revision #8173?
>






More information about the User mailing list