Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#3894 closed defect (fixed)

dladdr failed: not available on Windows failed

Reported by: Volker Waurich Owned by: Adrian Pop
Priority: high Milestone: Future
Component: Code Generation Version:
Keywords: Cc: Martin Sjölund, Adrian Pop, Willi Braun, Niklas Worschech

Description

Hi,

I get the following error dladdr failed: not available on Windows failed for almost any models I want to simulate on my Windows machine. I built omc using msys2 32bit.

The function call System.launchParallelTasks(numThreads, codegenFuncs, runCodegenFunc)); in SimCodeMain.mo causes this error. Setting num_threads to a value less than 6 works for my 6-core. But default is 12.

So something in the c-codegeneration fails:

Errors: Failed to build model: Modelica.Blocks.Examples.BooleanNetwork1Error: Failed to write to file (not open)
Error: Template error: A template call failed (a call with 0 parameters: dladdr failed: not available on Windows). One possible reason could be that a template imported function ca
ll failed (which should not happen for functions called from within template code; templates preserve pure 'match'/non-failing semantics).

As a result the following generated files are empty:
*_15syn.c, *_11mix.h, *._includes.h and hence, compilation fails due to missing references.

Change History (12)

comment:1 by Martin Sjölund, 9 years ago

Try setting a breakpoint in om_file_write in File.mo to debug this. The issue does not appear in Linux as far as I can tell, and this only happens if a File external object is NULL.

Also: Is there any limit on the maximum number of open files on Windows?

comment:2 by Niklas Worschech, 8 years ago

Are there any news to this ticket. On Windows, it is no longer possible to simulate a model with the c runtime since 5 months.

comment:3 by Martin Sjölund, 8 years ago

I did not look into this further since I got no more user input.

comment:4 by Niklas Worschech, 8 years ago

Cc: Willi Braun Niklas Worschech added

comment:5 by Volker Waurich, 8 years ago

This issue might be solved by 0358b6
I have tested it quickly and the dladdr message does no longer show up.

Maybe niklwors can try it out on Windows as well?

Thanks sjoelund.se

comment:6 by Adrian Pop, 8 years ago

Owner: changed from Lennart Ochel to Adrian Pop
Status: newaccepted

This still happens on 32 bit. I tested it a bit on my computer. Whenever you set n>=6 the parallel code generation gets to File.write with a FILE pointer 0. I'll debug some more.

comment:7 by Adrian Pop, 8 years ago

The problem is in Tpl.tokFileText which creates a File.File via the constructor using:

File.File file = File.File(getTextOpaqueFile(inText));

and then recursively calls itself via Tpl.handleTok which SOMEHOW overrides the file if there are several threads. I don't quite understand why this happens, maybe the thread stack is overrun?

comment:8 by Adrian Pop, 8 years ago

The problem was that the given *existing* fromID input to the file constructor was actually making isNone return true. A fix is on the way.

comment:10 by Adrian Pop, 8 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in 057661/OMCompiler.

comment:11 by Martin Sjölund, 8 years ago

Seems like an odd File interface change, passing a filename and boolean but then not using the filename. filename should be set only when opening a file (and not in the constructor). It also makes a weird default, where before you just said File() when you wanted to create a File object not bound to any file. Now you need to pass File(NONE(), "dummyFileName", true)...

And the odd behaviour of passing both an Option<File> and a boolean seems odd. The bug where isNone() returned true for existing files is not documented in the source code either, which probably would lead to the code being re-written in the future. And anyway, it just seems like a hack that avoids fixing the returned value of Option<Integer> on 32-bit Windows. It could be a quite serious issue causing multiple crashes that should have been fixed.

in reply to:  11 comment:12 by Adrian Pop, 8 years ago

Replying to sjoelund.se:

Seems like an odd File interface change, passing a filename and boolean but then not using the filename. filename should be set only when opening a file (and not in the constructor). It also makes a weird default, where before you just said File() when you wanted to create a File object not bound to any file. Now you need to pass File(NONE(), "dummyFileName", true)...

Not true. You can do File(); without any issue as all parameters have a default.

And the odd behaviour of passing both an Option<File> and a boolean seems odd. The bug where isNone() returned true for existing files is not documented in the source code either, which probably would lead to the code being re-written in the future. And anyway, it just seems like a hack that avoids fixing the returned value of Option<Integer> on 32-bit Windows. It could be a quite serious issue causing multiple crashes that should have been fixed.

I think you're completely mistaken here. There is nothing to fix, you used Option<Integer> to pass an opaque FILE* pointer which in some cases returns true for isNone. We should extend MetaModelica with a real opaque pointer.

Note: See TracTickets for help on using tickets.