bugGnash - The GNU Flash player - Bugs: bug #15417, gnash fails assertion on testsuite

 
 

bug #15417: gnash fails assertion on testsuite

Submitted by:  None
Submitted on:  Tue 10 Jan 2006 09:01:34 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Release: NoneStatus: In Progress
Privacy: PublicAssigned to: Rob Savoye <rsavoye>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 26 Jan 2006 05:20:20 PM UTC, comment #4:

This has been fixed by changing the data type from an int to a size_t, which is a 64 bit type which fixes this assertion problem.

Rob Savoye <rsavoye>
Project AdministratorIn charge of this item.
Fri 20 Jan 2006 11:02:45 PM UTC, comment #3:

For me, this patch breaks something when trying to play Elvis, so somewhere, something is expected a long when it really wants an int. Can you play Elvis with your original patched version ?

Rob Savoye <rsavoye>
Project AdministratorIn charge of this item.
Tue 10 Jan 2006 09:50:42 PM UTC, comment #2:

patch to fix it :

This patch removes int in the STL-homemade implementation
int is not portable
long is portable ;)

some other ints may need to be removed in the code elsewhere, I have not checked, but this patch is sufficient to run the testsuite on the commandline.

Index: container.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/container.h,v
retrieving revision 1.1
diff -u -r1.1 container.h
--- container.h 20 Dec 2005 20:57:00 -0000 1.1
+++ container.h 10 Jan 2006 21:48:20 -0000
@@ -36,7 +36,7 @@
size_t operator()(const T& data) const
{
unsigned char* p = (unsigned char*) &data;
- int size = sizeof(T);
+ long size = sizeof(T);

return sdbm_hash(p, size);
}
@@ -203,7 +203,7 @@
// they are added or removed from the active part of the array.
public:
array() : m_buffer(0), m_size(0), m_buffer_size(0) {}
- array(int size_hint) : m_buffer(0), m_size(0), m_buffer_size(0) { resize(size_hint); }
+ array(long size_hint) : m_buffer(0), m_size(0), m_buffer_size(0) { resize(size_hint); }
array(const array<T>& a)
:
m_buffer(0),
@@ -217,9 +217,9 @@
}

// Basic array access.
- T& operator[](int index) { assert(index >= 0 && index < m_size); return m_buffer[index]; }
- const T& operator[](int index) const { assert(index >= 0 && index < m_size); return m_buffer[index]; }
- int size() const { return m_size; }
+ T& operator[](long index) { assert(index >= 0 && index < m_size); return m_buffer[index]; }
+ const T& operator[](long index) const { assert(index >= 0 && index < m_size); return m_buffer[index]; }
+ long size() const { return m_size; }

void push_back(const T& val)
// Insert the given element at the end of the array.
@@ -229,7 +229,7 @@
// resize() may munge the element storage!
assert(&val < &m_buffer[0] || &val > &m_buffer[m_buffer_size]);

- int new_size = m_size + 1;
+ long new_size = m_size + 1;
resize(new_size);
(*this)[new_size-1] = val;
}
@@ -261,13 +261,13 @@
// Array copy. Copies the contents of a into this array.
{
resize(a.size());
- for (int i = 0; i < m_size; i++) {
+ for (long i = 0; i < m_size; i++) {
*(m_buffer + i) = a[i];
}
}

- void remove(int index)
+ void remove(long index)
// Removing an element from the array is an expensive operation!
// It compacts only after removing the last element.
{
@@ -287,7 +287,7 @@
}

- void insert(int index, const T& val = T())
+ void insert(long index, const T& val = T())
// Insert the given object at the given index shifting all the elements up.
{
assert(index >= 0 && index <= m_size);
@@ -312,7 +312,7 @@
}

- void append(const T other[], int count)
+ void append(const T other[], long count)
// Append the given data to our array.
{
if (count > 0)
@@ -328,7 +328,7 @@
}

- void resize(int new_size)
+ void resize(long new_size)
// Preserve existing elements via realloc.
//
// Newly created elements are initialized with default element
@@ -336,11 +336,11 @@
{
assert(new_size >= 0);

- int old_size = m_size;
+ long old_size = m_size;
m_size = new_size;

// Destruct old elements (if we're shrinking).
- {for (int i = new_size; i < old_size; i++) {
+ {for (long i = new_size; i < old_size; i++) {
(m_buffer + i)->~T();
}}

@@ -351,24 +351,24 @@
// don't compact yet.
assert(m_buffer != 0);
} else {
- int new_buffer_size = m_size + (m_size >> 2);
+ long new_buffer_size = m_size + (m_size >> 2);
reserve(new_buffer_size);
}

// Copy default T into new elements.
- {for (int i = old_size; i < new_size; i++) {
+ {for (long i = old_size; i < new_size; i++) {
new (m_buffer + i) T(); // placement new
}}
}

- void reserve(int rsize)
+ void reserve(long rsize)
// @@ TODO change this to use ctor, dtor, and operator=
// instead of preserving existing elements via binary copy via
// realloc?
{
assert(m_size >= 0);

- int old_size = m_buffer_size;
+ long old_size = m_buffer_size;
old_size = old_size; // don't warn that this is unused.
m_buffer_size = rsize;

@@ -404,8 +404,8 @@

private:
T* m_buffer;
- int m_size;
- int m_buffer_size;
+ long m_size;
+ long m_buffer_size;
};

@@ -423,7 +423,7 @@
// table will be, default it to that size when you create it.
public:
hash() : m_table(NULL) { }
- hash(int size_hint) : m_table(NULL) { set_capacity(size_hint); }
+ hash(long size_hint) : m_table(NULL) { set_capacity(size_hint); }
~hash() { clear(); }

hash(const hash<T,U,hash_functor>& src)
@@ -452,7 +452,7 @@
void set(const T& key, const U& value)
// Set a new or existing value under the key, to the value.
{
- int index = find_index(key);
+ long index = find_index(key);
if (index >= 0)
{
E(index).second = value;
@@ -473,7 +473,7 @@
m_table->m_entry_count++;

unsigned int hash_value = hash_functor()(key);
- int index = hash_value & m_table->m_size_mask;
+ long index = hash_value & m_table->m_size_mask;

entry* natural_entry = &(E(index));

@@ -485,7 +485,7 @@
else
{
// Find a blank spot.
- int blank_index = index;
+ long blank_index = index;
for (;;)
{
blank_index = (blank_index + 1) & m_table->m_size_mask;
@@ -493,7 +493,7 @@
}
entry* blank_entry = &E(blank_index);

- if (int(natural_entry->m_hash_value & m_table->m_size_mask) == index)
+ if (long(natural_entry->m_hash_value & m_table->m_size_mask) == index)
{
// Collision. Link into this chain.

@@ -513,7 +513,7 @@
// entry must be moved.

// Find natural location of collided element (i.e. root of chain)
- int collided_index = natural_entry->m_hash_value & m_table->m_size_mask;
+ long collided_index = natural_entry->m_hash_value & m_table->m_size_mask;
for (;;)
{
entry* e = &E(collided_index);
@@ -543,7 +543,7 @@
if (m_table)
{
// Delete the entries.
- for (int i = 0, n = m_table->m_size_mask; i <= n; i++)
+ for (long i = 0, n = m_table->m_size_mask; i <= n; i++)
{
entry* e = &E(i);
if (e->is_empty() == false)
@@ -575,7 +575,7 @@
// If value == NULL, return true or false according to the
// presence of the key, but don't touch *value.
{
- int index = find_index(key);
+ long index = find_index(key);
if (index >= 0)
{
if (value) {
@@ -587,7 +587,7 @@
}

- int size()
+ long size()
{
return m_table == NULL ? 0 : m_table->m_entry_count;
}
@@ -619,12 +619,12 @@
set_capacity(n);
}

- void set_capacity(int new_size)
+ void set_capacity(long new_size)
// Size the hash so that it can comfortably contain the given
// number of elements. If the hash already contains more
// elements than new_size, then this may be a no-op.
{
- int new_raw_size = (new_size * 3) / 2;
+ long new_raw_size = (new_size * 3) / 2;
if (new_raw_size < size()) { return; }

set_raw_capacity(new_raw_size);
@@ -633,7 +633,7 @@
// Behaves much like std::pair
struct entry
{
- int m_next_in_chain; // internal chaining for collisions
+ long m_next_in_chain; // internal chaining for collisions
size_t m_hash_value; // avoids recomputing. Worthwhile?
T first;
U second;
@@ -643,7 +643,7 @@
: m_next_in_chain(e.m_next_in_chain), m_hash_value(e.m_hash_value), first(e.first), second(e.second)
{
}
- entry(const T& key, const U& value, int next_in_chain, int hash_value)
+ entry(const T& key, const U& value, long next_in_chain, long hash_value)
: m_next_in_chain(next_in_chain), m_hash_value(hash_value), first(key), second(value)
{
}
@@ -724,7 +724,7 @@
}

const hash* m_hash;
- int m_index;
+ long m_index;
};
friend struct const_iterator;

@@ -756,7 +756,7 @@
if (m_table == 0) return iterator(NULL, 0);

// Scan til we hit the first valid entry.
- int i0 = 0;
+ long i0 = 0;
while (i0 <= m_table->m_size_mask
&& E(i0).is_empty())
{
@@ -771,7 +771,7 @@

iterator find(const T& key)
{
- int index = find_index(key);
+ long index = find_index(key);
if (index >= 0)
{
return iterator(this, index);
@@ -783,17 +783,17 @@

private:

- int find_index(const T& key) const
+ long find_index(const T& key) const
// Find the index of the matching entry. If no match, then return -1.
{
if (m_table == NULL) return -1;

size_t hash_value = hash_functor()(key);
- int index = hash_value & m_table->m_size_mask;
+ long index = hash_value & m_table->m_size_mask;

const entry* e = &E(index);
if (e->is_empty()) return -1;
- if (int(e->m_hash_value & m_table->m_size_mask) != index) return -1; // occupied by a collider
+ if (long(e->m_hash_value & m_table->m_size_mask) != index) return -1; // occupied by a collider

for (;;)
{
@@ -819,13 +819,13 @@
}

// Helpers.
- entry& E(int index)
+ entry& E(long index)
{
assert(m_table);
assert(index >= 0 && index <= m_table->m_size_mask);
return (((entry) (m_table + 1)) + index);
}
- const entry& E(int index) const
+ const entry& E(long index) const
{
assert(m_table);
assert(index >= 0 && index <= m_table->m_size_mask);
@@ -833,7 +833,7 @@
}

- void set_raw_capacity(int new_size)
+ void set_raw_capacity(long new_size)
// Resize the hash table to the given size (Rehash the
// contents of the current table). The arg is the number of
// hash table entries, not the number of elements we should
@@ -846,7 +846,7 @@
}

// Force new_size to be a power of two.
- int bits = fchop(log2((float)(new_size-1)) + 1);
+ long bits = fchop(log2((float)(new_size-1)) + 1);
assert((1 << bits) >= new_size);

new_size = 1 << bits;
@@ -864,7 +864,7 @@

new_hash.m_table->m_entry_count = 0;
new_hash.m_table->m_size_mask = new_size - 1;
- {for (int i = 0; i < new_size; i++)
+ {for (long i = 0; i < new_size; i++)
{
new_hash.E(i).m_next_in_chain = -2; // mark empty
}}
@@ -872,7 +872,7 @@
// Copy stuff to new_hash
if (m_table)
{
- for (int i = 0, n = m_table->m_size_mask; i <= n; i++)
+ for (long i = 0, n = m_table->m_size_mask; i <= n; i++)
{
entry* e = &E(i);
if (e->is_empty() == false)
@@ -894,8 +894,8 @@

struct table
{
- int m_entry_count;
- int m_size_mask;
+ long m_entry_count;
+ long m_size_mask;
// entry array goes here!
};
table* m_table;

Anonymous
Tue 10 Jan 2006 09:20:53 PM UTC, comment #1:

tried _TU_USE_STL=1 but it cannot be compiled (whatever STL headers are used ...)

Anonymous
Tue 10 Jan 2006 09:01:34 PM UTC, original submission:

I am running debian sid amd64 (with nvidia' s stuff)
(gnash cvs compiled from today)

steps to reproduce :
gnash testsuite/movies.all/elvis.swf

leads to :
gnash: ../libbase/container.h:807: int hash<T, U, hash_functor>::find_index(const T&) const [with T = int, U = void ()(gnash::stream, int, gnash::movie_definition_sub*), hash_functor = fixed_size_hash<int>]: Assertion `! (e->first == key)' failed.

Backtrace :
#0 0x00002aaaaccc1df0 in raise () from /lib/libc.so.6
#1 0x00002aaaaccc32a0 in abort () from /lib/libc.so.6
#2 0x00002aaaaccbaffb in __assert_fail () from /lib/libc.so.6
#3 0x00002aaaaae8372d in hash<int, void ()(gnash::stream, int, gnash::movie_definition_sub*), fixed_size_hash<int> >::find_index (this=<value optimized out>, key=<value optimized out>)
at container.h:807
#4 0x00002aaaaae8f044 in gnash::movie_def_impl::read (this=0x688880, in=<value optimized out>) at container.h:578
#5 0x00002aaaaae7fa0f in gnash::create_movie_sub (filename=0x7fffffebeb16 "testsuite/movies.all/elvis.swf") at impl.cpp:1458
#6 0x00002aaaaae7fcd8 in gnash::create_library_movie_sub (filename=0x7fffffebeb16 "testsuite/movies.all/elvis.swf") at impl.cpp:1631
#7 0x00002aaaaae80159 in gnash::create_library_movie (filename=0x4de4 <Address 0x4de4 out of bounds>) at impl.cpp:1610
#8 0x000000000040792d in main (argc=2, argv=0x7fffffebd988) at gnash.cpp:495

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 3 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 26 Jan 2006 05:20:20 PM UTCrsavoyeOpen/ClosedOpen=>Closed
Fri 20 Jan 2006 11:02:45 PM UTCrsavoyeStatusNone=>In Progress
  Assigned toNone=>rsavoye

Back to the top


Powered by Savane 3.1-cleanup1