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 » [SOLVED] Invalid memory access on ImageDraw::Init (X11)
[SOLVED] Invalid memory access on ImageDraw::Init (X11) [message #52013] Thu, 04 July 2019 18:05 Go to next message
Xemuth is currently offline  Xemuth
Messages: 307
Registered: August 2018
Location: France
Senior Member
Hello,

On my raspberryPi, this code :
PNGEncoder png;
png.SaveFile("temp.png", myGraph.DrawGraph()); //myGraph.DrawGraph() return me an ImageDraw

Raise an "invalid memory access" error :
https://i.imgur.com/BkFnRjM.png
Just to try, I did a "sudo chmod 777" to the folder and program and error still happening.

Do someone have any idea ?

Thanks in advance.
Have a nice day


[Updated on: Mon, 08 July 2019 08:57]

Report message to a moderator

Re: Invalid memory access while PNGEncoder.SaveFile() [message #52014 is a reply to message #52013] Thu, 04 July 2019 20:21 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1133
Registered: December 2006
Senior Contributor
Compile a debug version of your app (or Release with debug information).
Run it with gdb.
When it crashes run a gdb command "bt".
Post its output here ...


Regards,
Novo
Re: Invalid memory access while PNGEncoder.SaveFile() [message #52015 is a reply to message #52013] Thu, 04 July 2019 20:23 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 822
Registered: September 2012
Location: Poland, Kraków
Experienced Contributor
Hello,

Please post call-stack from TheIDE - you need to catch the crash and make print screen with open call stack. I will be working on copy to clipboard option - https://www.ultimatepp.org/redmine/issues/1972.

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.
Re: Invalid memory access while PNGEncoder.SaveFile() [message #52016 is a reply to message #52015] Thu, 04 July 2019 20:51 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1133
Registered: December 2006
Senior Contributor
Klugier wrote on Thu, 04 July 2019 14:23
Hello,

Please post call-stack from TheIDE - you need to catch the crash and make print screen with open call stack. I will be working on copy to clipboard option - https://www.ultimatepp.org/redmine/issues/1972.

Sincerely,
Klugier

AFAIK, this is already implemented: Debug -> "Copy backtrace".


Regards,
Novo
Re: Invalid memory access while PNGEncoder.SaveFile() [message #52017 is a reply to message #52013] Thu, 04 July 2019 21:42 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 307
Registered: August 2018
Location: France
Senior Member
Invalid memory access!
X Error of failed request:  BadFont (invalid Font parameter)
  Major opcode of failed request:  46 (X_CloseFont)
  Resource id in failed request:  0x1200002
  Serial number of failed request:  23
  Current serial number in output stream:  26

by using debug I can figure out PNG Encoder have nothing to do with my crash.
Apprently, the cause is the problem, Since I use StdFont (const Integer That Represent my Font Size) everywhere, maybe can stdFont is buggy on Raspbery / Debian ??


Re: Invalid memory access while PNGEncoder.SaveFile() [message #52018 is a reply to message #52013] Thu, 04 July 2019 21:58 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 307
Registered: August 2018
Location: France
Senior Member
void Font::InitStdFont()
{
	ONCELOCK { // TODO: This is now sort of obsolete function....
	//	Mutex::Lock __(sFontLock);
	//	FaceList();
		AStdFont = Arial(12);
	//	SyncStdFont();
	}
}

Maybe Arial does not exist on raspbian and it occurs a Crash?


Re: Invalid memory access while PNGEncoder.SaveFile() [message #52019 is a reply to message #52013] Thu, 04 July 2019 22:08 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 307
Registered: August 2018
Location: France
Senior Member
Or Maybe since I compiled my project only with the "NOGTK" flags the ImageDraw used is the windows version https://i.imgur.com/EYixcNT.png Trying to recompile it with X11 flag

Re: Invalid memory access on ImageDraw::Init (X11) [message #52020 is a reply to message #52013] Thu, 04 July 2019 22:55 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 307
Registered: August 2018
Location: France
Senior Member
Ok, after recompiling with only "X11" flag and running the programm in debug Mode :

The programm crash at this line : (ImageX11.cpp, CtrlCore)
void ImageDraw::Init()
{
	GuiLock __;
	dw = XCreatePixmap(Xdisplay, Xroot, max(size.cx, 1), max(size.cy, 1), Xdepth);  //This line generate the crash
	gc = XCreateGC(Xdisplay, dw, 0, 0);
	xftdraw = XftDrawCreate(Xdisplay, (Drawable) dw, DefaultVisual(Xdisplay, Xscreenno), Xcolormap);

	alpha.dw = XCreatePixmap(Xdisplay, Xroot, max(size.cx, 1), max(size.cy, 1), Xdepth);
	alpha.gc = XCreateGC(Xdisplay, alpha.dw, 0, 0);
	alpha.xftdraw = XftDrawCreate(Xdisplay, (Drawable) alpha.dw, DefaultVisual(Xdisplay, Xscreenno), Xcolormap);

	Vector<Rect> clip;
	clip.Add(RectC(0, 0, size.cx, size.cy));
	SystemDraw::Init(clip, Point(0, 0));
	alpha.Init(clip, Point(0, 0));

	has_alpha = false;
}


The PANIC message on console is :
****************** PANIC: Invalid memory access!

Invalid memory access!
X Error of failed request:  BadFont (invalid Font parameter)
  Major opcode of failed request:  46 (X_CloseFont)
  Resource id in failed request:  0x1400002
  Serial number of failed request:  23



Here is BackTrace :
----------------------------------
Thread: 1

XCreatePixmap () from /usr/lib/arm-linux-gnueabihf/libX11.so.6
Upp::ImageDraw::Init (this=0x7effd4d8) at /home/xemuth/upp/uppsrc/CtrlCore/ImageX11.cpp:270
Upp::ImageDraw::ImageDraw (this=0x7effd4d8, cx=1920, cy=1080) at /home/xemuth/upp/uppsrc/CtrlCore/ImageX11.cpp:377
GraphDotCloud::GraphDotCloud (this=0x7effd448, _XSize=1920, _YSize=1080, _GraphName=..., _XName=..., _YName=...) at /home/xemuth/Upp/myApps/GraphBuilder/GraphBuilder.cpp:729
Discord_Overwatch::DrawStatsEquipe (this=0x7effe340, payload=...) at /home/xemuth/Upp/myApps/Discord_Overwatch/Discord_Overwatch.cpp:652
Discord_Overwatch::<lambda(Upp::ValueMap)>::operator()(Upp::ValueMap) const (__closure=0x748f65d8, e=...) at /home/xemuth/Upp/myApps/Discord_Overwatch/Discord_Overwatch.cpp:54
Upp::Function<void(Upp::ValueMap)>::Wrapper<Discord_Overwatch::Discord_Overwatch(Upp::String, Upp::String)::<lambda(Upp::ValueMap)> >::Execute(Upp::ValueMap) (this=0x748f65d0, args#0=...) at /home/xemuth/upp/uppsrc/Core/Function.h:17
Upp::Function<void (Upp::ValueMap)>::operator()(Upp::ValueMap) const (this=0x74966c50, args#0=...) at /home/xemuth/upp/uppsrc/Core/Function.h:76
Discord_Overwatch::EventsMessageCreated (this=0x7effe340, payload=...) at /home/xemuth/Upp/myApps/Discord_Overwatch/Discord_Overwatch.cpp:60
SmartBotUpp::Event (this=0x7effe4f0, payload=...) at /home/xemuth/Upp/myApps/SmartUppBot/SmartBotUpp.cpp:65
SmartBotUpp::<lambda(Upp::ValueMap)>::operator()(Upp::ValueMap) const (__closure=0x748f65f8, payload=...) at /home/xemuth/Upp/myApps/SmartUppBot/SmartBotUpp.cpp:27
Upp::Function<void(Upp::ValueMap)>::Wrapper<SmartBotUpp::Launch()::<lambda(Upp::ValueMap)> >::Execute(Upp::ValueMap) (this=0x748f65f0, args#0=...) at /home/xemuth/upp/uppsrc/Core/Function.h:17
Upp::Function<void (Upp::ValueMap)>::operator()(Upp::ValueMap) const (this=0x7efff15c, args#0=...) at /home/xemuth/upp/uppsrc/Core/Function.h:76
Upp::Discord::Dispatch (this=0x7effe500, payload=...) at /home/xemuth/Upp/myApps/SmartUppBot/Discord.cpp:136
Upp::Discord::Listen (this=0x7effe500) at /home/xemuth/Upp/myApps/SmartUppBot/Discord.cpp:304
SmartBotUpp::Launch (this=0x7effe4f0) at /home/xemuth/Upp/myApps/SmartUppBot/SmartBotUpp.cpp:28
ConsoleMainFn_ () at /home/xemuth/Upp/myApps/SmartUppBot/main.cpp:25
Upp::AppExecute__ (app=0x19d54 <ConsoleMainFn_()>) at /home/xemuth/upp/uppsrc/Core/App.cpp:343
main (argc=1, argv=0x7efff5e4, envptr=0x7efff5ec) at /home/xemuth/Upp/myApps/SmartUppBot/main.cpp:14

----------------------------------
Thread: 3

nanosleep () at ../sysdeps/unix/syscall-template.S:84
Upp::Thread::Sleep (msec=41250) at /home/xemuth/upp/uppsrc/Core/Mt.cpp:407
Upp::Discord::RepeatSendHeartbeat (this=0x7effe500, ms=41250, keepRunning=...) at /home/xemuth/Upp/myApps/SmartUppBot/Discord.cpp:57
Upp::CallbackN<> Upp::callback2<Upp::Discord, Upp::Discord, int, std::reference_wrapper<std::atomic<bool> >, unsigned int, std::atomic<bool>&>(Upp::Discord*, void (Upp::Discord::*)(unsigned int, std::atomic<bool>&), int, std::reference_wrapper<std::atomic<bool> >)::{lambda()#1}::operator()() const (__closure=0x74984e98) at /home/xemuth/upp/uppsrc/Core/CallbackNP.i:38
Upp::Function<void ()>::Wrapper<Upp::CallbackN<> Upp::callback2<Upp::Discord, Upp::Discord, int, std::reference_wrapper<std::atomic<bool> >, unsigned int, std::atomic<bool>&>(Upp::Discord*, void (Upp::Discord::*)(unsigned int, std::atomic<bool>&), int, std::reference_wrapper<std::atomic<bool> >)::{lambda()#1}>::Execute() (this=0x74984e90) at /home/xemuth/upp/uppsrc/Core/Function.h:17
Upp::Function<void ()>::operator()() const (this=0x748f66b0) at /home/xemuth/upp/uppsrc/Core/Function.h:76
Upp::sThreadRoutine (arg=0x748f66b0) at /home/xemuth/upp/uppsrc/Core/Mt.cpp:83
start_thread (arg=0x7471e130) at pthread_create.c:458
/lib/arm-linux-gnueabihf/libc.so.6




My upp version is : 13469
My hardware is Raspberry pi 3b+


[Updated on: Thu, 04 July 2019 23:09]

Report message to a moderator

Re: Invalid memory access on ImageDraw::Init (X11) [message #52028 is a reply to message #52013] Mon, 08 July 2019 08:57 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 307
Registered: August 2018
Location: France
Senior Member
Hello, probleme just came from my code and not Upp.

Previous Topic: How do I add scrollbars to a dialog
Next Topic: Image Ctrl How To Add It???
Goto Forum:
  


Current Time: Tue Jan 19 08:57:08 CET 2021

Total time taken to generate the page: 0.01305 seconds