View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0034550||FPC||RTL||public||2018-11-13 21:18||2018-11-26 10:06|
|Reporter||CCRDude||Assigned To||Jonas Maebe|
|Status||resolved||Resolution||no change required|
|Summary||0034550: GetProcAddress for loaded .dylib returns nil for existing function with Cocoa (works with Carbon and on other platforms)|
|Description||If I have a valid library (*.dylib), I can successfully use LoadLibrary to get a handle, but GetProcAddress returns nil, while GetLastOSError returns success.|
The same test file works on other OS, and according to one forum user, even with Carbon on macOS, just not with Cocoa.
|Steps To Reproduce||1. Get test example from here: https://github.com/CCRDude/laz-darwin-dylib-test|
2. Compile both, run test executable. Fails from 3.0.4 to todays trunk.
3. Compile for Carbon instead of Cocoa, it should work now.
4. Compile for Windows, it works.
See comments here (reproduced by others as well):
|Tags||No tags attached.|
|Fixed in Revision|
1. GetLastOSError is meaningless for GetProcedureAddress functions. use GetLoadErrorStr to get errors.
If you do that, you'll get a "invalid handle passed to dlsym()" error.
2. And Cocoa/Carbon is not relevant for pure FPC programs
Re 1. I had found GetLoadErrorStr here:
"GetLoadErrorStr returns a textual description of the last library loading or unloading error. "
Since "GetProcedureAddress" is not a library loading or unloading action, I checked if its documentation would list an equivalent message, but found none. I recommend to update the manuals to better reflect the real behavior :)
Re 2. that was feedback I received on the forum. Just mentioned as an indicator to track differences.
||The documentation is indeed somewhat misleading. I corrected it in rev. 1518.|
||As documented at https://www.freepascal.org/docs-html/rtl/dynlibs/loadlibrary.html, the result of LoadLibrary is TLibHandle, not THandle. If you turn on range checking, you will also get an error about the truncation of the library handle at run time.|
|2018-11-13 21:18||CCRDude||New Issue|
|2018-11-13 23:28||Michael Van Canneyt||Note Added: 0111960|
|2018-11-14 07:32||CCRDude||Note Added: 0111962|
|2018-11-14 09:11||Michael Van Canneyt||Note Added: 0111963|
|2018-11-18 11:23||Jonas Maebe||Note Added: 0112035|
|2018-11-18 11:23||Jonas Maebe||Status||new => resolved|
|2018-11-18 11:23||Jonas Maebe||Resolution||open => no change required|
|2018-11-18 11:23||Jonas Maebe||Assigned To||=> Jonas Maebe|