It is currently Thu Nov 21, 2019 8:31 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: GP Fault when using GUI Functions in DLL
PostPosted: Tue May 07, 2013 1:45 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Apr 06, 2011 11:37 am
Posts: 103
Location: Hüfingen, Germany
This may be reported already, but i haven't been able to pin point my problem from other posts.
Here's a repro

This is libfoo.pb
Code:
ProcedureDLL test()
  IsWindow(23)
EndProcedure


This is footest.pb
Code:
Procedure foo()
  GadgetID(0)
EndProcedure

OpenLibrary(#PB_Any, "PureBasic.dll")
OpenWindow(0, 10, 10, 10, 10, "foo")


This is how i compile the DLL
Code:
pbcompiler.exe /DLL libfoo.pb

******************************************
PureBasic 5.11 (Windows - x86)
******************************************

Compiling libfoo.pb
Loading external libraries...
Starting compilation...
4 lines processed.
Creating DLL "PureBasic.dll"

- Feel the ..PuRe.. Power -


And here is footest.pb
Code:
pbcompiler.exe footest.pb

******************************************
PureBasic 5.11 (Windows - x86)
******************************************

Compiling footest.pb
Loading external libraries...
Starting compilation...
7 lines processed.
Creating and launching executable.

- Feel the ..PuRe.. Power -


When running the app it crashes at the end with an invalid memory access.
When compiling from the command line the pbcompiler already crashes in the "launching executable" part, but the exe is created.

When removing the IsWIndow call from libfoo.pb the problem goes away.
All this is happening on 32 bit XP. It's been reported on 32 Win7, but not on 64 Win 7. pbcompiler is always 32 bit.

When the DLL is compiled with pb >= 5.10 the executable crashes no matter what compiler.
When the DLL is compiled with pb <= 5.00 the executable works no matter what compiler.

This behaviour has not been observed with Linux or Mac.

PLaying with unicode or threaded switches makes no difference.

But then...

After poking this a bit more, i've found that adding a
Code:
CloseWindow(0)

to the end makes the GP fault go away.

Now one could clearly argue that this is not a PureBasic bug, and that the lazy programmer should do house cleaning.
I do agree with that, however.....

...this worked just fine until pb 5.10 and continues to work when running 32 bit pb on 64 Windows.
It fails in such an obscure way, that it literally ate a day of commenting lots of code out.
And then again to pin point a repro, that it would be a feature request that would save other victims of this considerable time.

So if it's possible to add some sort of error or warning, it would be a welcomed addition.

Maybe some of the other crashes i've noticed on the forum got bitten by the same issue.
I'm sure, i'm not the only sloppy coder here :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: GP Fault when using GUI Functions in DLL
PostPosted: Tue May 07, 2013 3:49 pm 
Offline
Addict
Addict

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 1056
Location: Russia
viewtopic.php?f=4&t=54536

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye