Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Segmentation Error, Assertion failed BiCont.h
Segmentation Error, Assertion failed BiCont.h [message #52724] Thu, 14 November 2019 10:43 Go to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello community,

My Question will may be stupid but I'm facing a recurente error occuring long time after I started my programme (~ 4Hours to 5 days( maximun I did)).
https://i.imgur.com/f1cMc2B.png

This error come from Head method in BiVector Class
T&       Head()                  { ASSERT(items > 0); return vector[start]; }


so Here is my questions, What head method is used for ? do it concern only Vector or Array use it aswell ?
Can you confirm my point of view : Upp calling Head before Doing any action on a Vector that could raise a crash ?

Some of vector used in my programm will sometime Stay "unchanged" by the programme during long period, Do the crash could come from that ? (may my OS will clears some memory slot if not used since a long time ?)

To End, have you some tips and trick to do propper code and prevent all this Boards effect that can be raised by a bad usage of Vector ?

Thanks in advance.
Have good day.
Best Regard.

Xemuth

Re: Segmentation Error, Assertion failed BiCont.h [message #52725 is a reply to message #52724] Thu, 14 November 2019 11:39 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello Xemuth,


Quote:

hat head method is used for ? do it concern only Vector or Array use it aswell ?


BiVector and BiArray are basically "bidirectional containers" that can act like queues (FIFO or LIFO). Smile

A head is basically the first element of that queue (BArray or BiVector). The same as vector[0];
A tail is basically the last element of that queue (BiArray or BiVector). the same as vector[vector.GetCount() - 1];

Api docs explain BiVectors and BiArrays. Here is an excerpt:

They "allows adding elements at both sides of sequence in constant amortized time."


T&       Head()                  { ASSERT(items > 0); return vector[start]; }


This means that your code is calling the Head method of a BiVector or BiArray in somewhere in your code, but the container appears to be empty at the time of call. Hence the assertion. Smile

Can you confirm my point of view : Upp calling Head before Doing any action on a Vector that could raise a crash ?


Probably. Because, as I pointed out above, the assertion you've got is a result of calling the Head method of an empty container.

Have you some tips and trick to do propper code and prevent all this Boards effect that can be raised by a bad usage of Vector ? 


Bounds checking or using IsEmpty() method, where appropriate, can save your time. Smile
Also check those containers whether they are picked or not. (Calling the Head method of a picked vector is illegal).


Best regards,
Oblivion


[Updated on: Thu, 14 November 2019 11:54]

Report message to a moderator

Re: Segmentation Error, Assertion failed BiCont.h [message #52726 is a reply to message #52724] Thu, 14 November 2019 11:56 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Thanks Oblivion for the quick response,

I will track it on my code to be sure.

However, I still got a blurred vision on why when my code running, the first 2 hours is ok, but after a long time this error will randomly spawn like one of my vector Have been emptied but my programme dont do that once. have you never encounter this kind of "case" ?
Re: Segmentation Error, Assertion failed BiCont.h [message #52727 is a reply to message #52726] Thu, 14 November 2019 12:11 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Quote:

However, I still got a blurred vision on why when my code running, the first 2 hours is ok, but after a long time this error will randomly spawn like one of my vector Have been emptied but my programme dont do that once. have you never encounter this kind of "case" ?


Hard for me to say...
If you are using containers extensively, you'll eventually gain a habit of checking them at some point. Smile


Possible clue: Do you use threads? If so, does this vector is shared between threads. or not local in any way? Then it might be a problem with thread access, in which case the thread is spawning before initialization or population of that vector. (i.e. a synchronization issue maybe?)

Best regards,
Oblivion


[Updated on: Thu, 14 November 2019 12:14]

Report message to a moderator

Re: Segmentation Error, Assertion failed BiCont.h [message #52728 is a reply to message #52727] Thu, 14 November 2019 12:19 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
[quote title=Oblivion wrote on Thu, 14 November 2019 12:11]Quote:

Possible clue: Do you use threads? If so, does this vector is shared between threads. or not local in any way? Then it might be a problem with thread access, in which case the thread is spawning before initialization or population of that vector. (i.e. a synchronization issue maybe?)



yes I do, Humm I had never thinking about it. Good Idea thanks !
Previous Topic: How I can load inside Utimate++ RayLib For MacOs And Win?
Next Topic: [SOLVED] Do Value can store anonymous function ?
Goto Forum:
  


Current Time: Thu Mar 28 15:11:02 CET 2024

Total time taken to generate the page: 0.01083 seconds