I'm trying to follow this tutorial on how to implement a solver, but I'm having troubles setting up the case.
The original case can be found here. At first, when running blockMesh my version of OpenFOAM didn't recognize #eval() in blockMeshDict, so I changed it for #calc:
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1e-4;
mergeType points; //Or: blockMesh -merge-points
wedgeAngle 2.5;
rodRadius 9.9;
airRadius 999;
tanAlpha #calc"tan(0.5*degToRad($wedgeAngle))";
posRodZ #calc"$rodRadius*$tanAlpha";
negRodZ #calc"-$posRodZ";
posAirZ #calc"$airRadius*$tanAlpha";
negAirZ #calc"-$posAirZ";
vertices
(
(0 0 0) // vertex #0
(100 0 0) // vertex #1
(100 $rodRadius $posRodZ) // vertex #2
(0 $rodRadius $posRodZ) // vertex #3
(0 $rodRadius $negRodZ) // vertex #4
(100 $rodRadius $negRodZ) // vertex #5
(0 $airRadius $posAirZ) // vertex #6
(100 $airRadius $posAirZ) // vertex #7
(100 $airRadius $negAirZ) // vertex #8
(0 $airRadius $negAirZ) // vertex #9
);
blocks
(
hex (0 1 5 4 0 1 2 3) (30 6 1) simpleGrading (1 1 1) // block #0
hex (4 5 8 9 3 2 7 6) (30 599 1) simpleGrading (1 1 1) // block #1
);
edges
(
);
boundary
(
leftWall
{
type patch;
faces
(
(3 4 0 0)
);
}
rightWall
{
type patch;
faces
(
(1 5 2 1)
);
}
atmosphereTop
{
type patch;
faces
(
(9 6 7 8)
);
}
atmosphereRight
{
type patch;
faces
(
(3 6 9 4)
);
}
atmosphereLeft
{
type patch;
faces
(
(5 8 7 2)
);
}
axis
{
type empty;
faces
(
(0 1 1 0)
);
}
rodBack
{
type wedge;
faces
(
(0 4 5 1)
);
}
rodFront
{
type wedge;
faces
(
(0 1 2 3)
);
}
airBack
{
type wedge;
faces
(
(4 9 8 5)
);
}
airFront
{
type wedge;
faces
(
(3 2 7 6)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
And now, when running blockMesh, I get the following errors:
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
Build : 9-c8374a4890ad
Exec : blockMesh
Date : Dec 16 2021
Time : 12:59:36
Host : "endeavouros"
PID : 346839
I/O : uncollated
Case : /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time
Reading "blockMeshDict"
Creating block mesh from
"system/blockMeshDict"
Using #calcEntry at line 26 in file "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict"
Using #codeStream with "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_28b21b5898ba159392899d5ac4d05a7158e0c6d6.so"
Creating new library in "dynamicCode/_28b21b5898ba159392899d5ac4d05a7158e0c6d6/platforms/linux64GccDPInt32Opt/lib/libcodeStream_28b21b5898ba159392899d5ac4d05a7158e0c6d6.so"
"/opt/OpenFOAM/OpenFOAM-9/etc/codeTemplates/dynamicCode/codeStreamTemplate.C" "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_28b21b5898ba159392899d5ac4d05a7158e0c6d6/codeStreamTemplate.C"
Invoking "wmake -s libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_28b21b5898ba159392899d5ac4d05a7158e0c6d6"
wmake libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_28b21b5898ba159392899d5ac4d05a7158e0c6d6
ln: ./lnInclude
wmkdep: codeStreamTemplate.C
Ctoo: codeStreamTemplate.C
ld: /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_28b21b5898ba159392899d5ac4d05a7158e0c6d6/../platforms/linux64GccDPInt32Opt/lib/libcodeStream_28b21b5898ba159392899d5ac4d05a7158e0c6d6.so
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Opening cached dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_28b21b5898ba159392899d5ac4d05a7158e0c6d6.so"
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Using #calcEntry at line 27 in file "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict"
Using #codeStream with "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_efc80fd5ffbc4db1928cd9ff3362f686671433be.so"
Creating new library in "dynamicCode/_efc80fd5ffbc4db1928cd9ff3362f686671433be/platforms/linux64GccDPInt32Opt/lib/libcodeStream_efc80fd5ffbc4db1928cd9ff3362f686671433be.so"
"/opt/OpenFOAM/OpenFOAM-9/etc/codeTemplates/dynamicCode/codeStreamTemplate.C" "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_efc80fd5ffbc4db1928cd9ff3362f686671433be/codeStreamTemplate.C"
Invoking "wmake -s libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_efc80fd5ffbc4db1928cd9ff3362f686671433be"
wmake libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_efc80fd5ffbc4db1928cd9ff3362f686671433be
ln: ./lnInclude
wmkdep: codeStreamTemplate.C
Ctoo: codeStreamTemplate.C
ld: /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_efc80fd5ffbc4db1928cd9ff3362f686671433be/../platforms/linux64GccDPInt32Opt/lib/libcodeStream_efc80fd5ffbc4db1928cd9ff3362f686671433be.so
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Opening cached dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_efc80fd5ffbc4db1928cd9ff3362f686671433be.so"
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Using #calcEntry at line 28 in file "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict"
Using #codeStream with "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_dc962d55c61555e401d9aa57fd57792f105fea79.so"
Creating new library in "dynamicCode/_dc962d55c61555e401d9aa57fd57792f105fea79/platforms/linux64GccDPInt32Opt/lib/libcodeStream_dc962d55c61555e401d9aa57fd57792f105fea79.so"
"/opt/OpenFOAM/OpenFOAM-9/etc/codeTemplates/dynamicCode/codeStreamTemplate.C" "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_dc962d55c61555e401d9aa57fd57792f105fea79/codeStreamTemplate.C"
Invoking "wmake -s libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_dc962d55c61555e401d9aa57fd57792f105fea79"
wmake libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_dc962d55c61555e401d9aa57fd57792f105fea79
ln: ./lnInclude
wmkdep: codeStreamTemplate.C
Ctoo: codeStreamTemplate.C
ld: /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_dc962d55c61555e401d9aa57fd57792f105fea79/../platforms/linux64GccDPInt32Opt/lib/libcodeStream_dc962d55c61555e401d9aa57fd57792f105fea79.so
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Opening cached dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_dc962d55c61555e401d9aa57fd57792f105fea79.so"
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Using #calcEntry at line 29 in file "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict"
Using #codeStream with "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_4510c2296fa7a962a6a70dda03e9219ebc01dac4.so"
Creating new library in "dynamicCode/_4510c2296fa7a962a6a70dda03e9219ebc01dac4/platforms/linux64GccDPInt32Opt/lib/libcodeStream_4510c2296fa7a962a6a70dda03e9219ebc01dac4.so"
"/opt/OpenFOAM/OpenFOAM-9/etc/codeTemplates/dynamicCode/codeStreamTemplate.C" "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_4510c2296fa7a962a6a70dda03e9219ebc01dac4/codeStreamTemplate.C"
Invoking "wmake -s libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_4510c2296fa7a962a6a70dda03e9219ebc01dac4"
wmake libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_4510c2296fa7a962a6a70dda03e9219ebc01dac4
ln: ./lnInclude
wmkdep: codeStreamTemplate.C
Ctoo: codeStreamTemplate.C
ld: /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_4510c2296fa7a962a6a70dda03e9219ebc01dac4/../platforms/linux64GccDPInt32Opt/lib/libcodeStream_4510c2296fa7a962a6a70dda03e9219ebc01dac4.so
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Opening cached dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_4510c2296fa7a962a6a70dda03e9219ebc01dac4.so"
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Using #calcEntry at line 30 in file "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict"
Using #codeStream with "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_0af64279ad3a68c6091e4927dfe1317848075c64.so"
Creating new library in "dynamicCode/_0af64279ad3a68c6091e4927dfe1317848075c64/platforms/linux64GccDPInt32Opt/lib/libcodeStream_0af64279ad3a68c6091e4927dfe1317848075c64.so"
"/opt/OpenFOAM/OpenFOAM-9/etc/codeTemplates/dynamicCode/codeStreamTemplate.C" "/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_0af64279ad3a68c6091e4927dfe1317848075c64/codeStreamTemplate.C"
Invoking "wmake -s libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_0af64279ad3a68c6091e4927dfe1317848075c64"
wmake libso /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_0af64279ad3a68c6091e4927dfe1317848075c64
ln: ./lnInclude
wmkdep: codeStreamTemplate.C
Ctoo: codeStreamTemplate.C
ld: /home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/_0af64279ad3a68c6091e4927dfe1317848075c64/../platforms/linux64GccDPInt32Opt/lib/libcodeStream_0af64279ad3a68c6091e4927dfe1317848075c64.so
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Opening cached dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_0af64279ad3a68c6091e4927dfe1317848075c64.so"
codeStream : dictionary:"/home/ariedinger/uni/gimap/openfoam/03emf/01huang/0rodFoam/rodFoamCase/system/blockMeshDict" master-only-reading:1
Creating block edges
No non-planar block faces defined
Creating topology blocks
#0 Foam::error::printStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 ? in "/usr/lib/libc.so.6"
#3 Foam::face::centre(Foam::Field<Foam::Vector<double> > const&) const at ??:?
#4 Foam::blockDescriptor::check(Foam::Istream const&) at ??:?
#5 Foam::blockDescriptor::blockDescriptor(Foam::dictionary const&, int, Foam::Field<Foam::Vector<double> > const&, Foam::PtrList<Foam::blockEdge> const&, Foam::PtrList<Foam::blockFace> const&, Foam::Istream&) at ??:?
#6 Foam::block::block(Foam::dictionary const&, int, Foam::Field<Foam::Vector<double> > const&, Foam::PtrList<Foam::blockEdge> const&, Foam::PtrList<Foam::blockFace> const&, Foam::Istream&) at ??:?
#7 Foam::block::New(Foam::dictionary const&, int, Foam::Field<Foam::Vector<double> > const&, Foam::PtrList<Foam::blockEdge> const&, Foam::PtrList<Foam::blockFace> const&, Foam::Istream&) at ??:?
#8 void Foam::PtrList<Foam::block>::read<Foam::block::iNew>(Foam::Istream&, Foam::block::iNew const&) at ??:?
#9 Foam::blockMesh::createTopology(Foam::IOdictionary const&, Foam::word const&) at ??:?
#10 Foam::blockMesh::blockMesh(Foam::IOdictionary const&, Foam::word const&) at ??:?
#11 ? in "/opt/OpenFOAM/OpenFOAM-9/platforms/linux64GccDPInt32Opt/bin/blockMesh"
#12 __libc_start_main in "/usr/lib/libc.so.6"
#13 ? in "/opt/OpenFOAM/OpenFOAM-9/platforms/linux64GccDPInt32Opt/bin/blockMesh"
fish: Job 2, 'blockMesh' terminated by signal SIGFPE (Floating point exception)
So, I'm a bit at lost on where to look and I'd appreciate some tips to try and solve the error.
Besides changing #eval() for #calc in blockMeshDict, everything else is pretty much the same as in the original case but here are the rest of my files.
The given case appears to be built for OpenFOAM v2, and I'm trying to run it on OpenFOAM v9 (installed from the package openfoam-org from the AUR). So, maybe that would be a problem? Nonetheless, in the course the case was given in 2020 (look at Implement electromagnetic solver Case: rodFoamCase.tgz in Proceedings 2020).
Thanks in advance.
It would be worthwhile to test with "openfoam-com" as well to see if there is a difference there. Can either use an AUR recipe or (probably faster) test with a docker instance and openfom.com
https://develop.openfoam.com/Development/openfoam/-/wikis/precompiled/docker
Related
When I am trying to run the following code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
vector<vector<int>> v(n, vector<int>(2));
cout<<2<<"\n";
return 0;
}
using the command g++ file.cpp then it is giving the following error
0 0x1022a41a0 __assert_rtn + 140
1 0x10212ba8c mach_o::relocatable::Parser<arm64>::parse(mach_o::relocatable::ParserOptions const&) + 4536
2 0x1020fdd38 mach_o::relocatable::Parser<arm64>::parse(unsigned char const*, unsigned long long, char const*, long, ld::File::Ordinal, mach_o::relocatable::ParserOptions const&) + 148
3 0x1021664ac ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool) + 1468
4 0x102169360 ___ZN2ld4tool10InputFilesC2ER7Options_block_invoke + 56
5 0x1c17b41f4 _dispatch_client_callout2 + 20
6 0x1c17c8f8c _dispatch_apply_invoke_and_wait + 224
7 0x1c17c826c _dispatch_apply_with_attr_f + 1152
8 0x1c17c847c dispatch_apply + 108
9 0x1021691f4 ld::tool::InputFiles::InputFiles(Options&) + 616
10 0x1020eb6c0 main + 552
A linker snapshot was created at:
/tmp/a.out-2022-09-19-011653.ld-snapshot
ld: Assertion failed: (_file->_atomsArrayCount == computedAtomCount && "more atoms allocated than expected"), function parse, file macho_relocatable_file.cpp, line 2061.
collect2: error: ld returned 1 exit status
void print(char *s) {
printf("%s\n", s);
}
I want to insert a call to the function above in an llvm pass. Here's my llvm pass code
Function *printFunc = M.getFunction("print");
if (printFunc) {
IRBuilder<> B(BB);
errs() << "print function: " << printFunc << "\n";
Value *v = B.CreateGlobalString("hi", "str");
ArrayRef<Value *> args(v);
Instruction *newInst = CallInst::Create(printFunc, args, "");
BB->getInstList().insert(I->getNextNode(), newInst);
}
Got the following error message:
opt: /workspace/LLVM_package/src/lib/IR/Instructions.cpp:279: void llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
0 opt 0x0000560a880abc62 llvm::sys::PrintStackTrace(_IO_FILE*) + 50
1 opt 0x0000560a880ab43c
2 libpthread.so.0 0x00007f8bd59d6800
3 libc.so.6 0x00007f8bd5476ce5 gsignal + 325
4 libc.so.6 0x00007f8bd5460857 abort + 299
5 libc.so.6 0x00007f8bd5460727
6 libc.so.6 0x00007f8bd546f426
7 opt 0x0000560a880177c1 llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&) + 465
8 MyLLVMPass.so 0x00007f8bd5431377
9 opt 0x0000560a88036636 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 822
10 opt 0x0000560a8724d072 main + 2626
11 libc.so.6 0x00007f8bd5462023 __libc_start_main + 243
12 opt 0x0000560a87267afe _start + 46
Stack dump:
0. Program arguments: opt -S -analyze -load ./build/Release+Asserts/lib/MyLLVMPass.so -MyLLVMPass
1. Running pass 'MyLLVMPass' on module '<stdin>'.
run_myllvmpass.sh: line 11: 60257 Aborted (core dumped) opt -S -analyze -load ./build/Release+Asserts/lib/MyLLVMPass.so -MyLLVMPass < ${var1} > ${var2}
Can anyone point out what I did wrong?
Your print function expects a pointer of type i8* but B.CreateGlobalString("hi", "str"); returns a pointer to an array of type i8. Use B.CreateGlobalStringPtr("hi", "str"); instead.
Application build with "release" settings in QtCreator builds and runs fine.
Building / running the code with "debug" fails at startup of application with the following error on console and crash report.
Build Info:
Qt Creator 4.2.2
Based on Qt 5.8.0 (Clang 7.0 (Apple), 64 bit)
Erstellt am Apr 3 2017 04:09:42
Revision 991f5eb6a5
Console Output :
QML debugging is enabled. Only use this in a safe environment.
dyld: lazy symbol binding failed: Symbol not found: __ZN9QCFString9toQStringEPK10__CFString
Referenced from: /Users/manuel/projects/rawstack/build-debug/app/rawstack.app/Contents/PlugIns/platforms/libqcocoa.dylib
Expected in: /Users/manuel/Qt/5.8/clang_64/lib/QtCore.framework/Versions/5/QtCore_debug
dyld: Symbol not found: __ZN9QCFString9toQStringEPK10__CFString
Referenced from: /Users/manuel/projects/rawstack/build-debug/app/rawstack.app/Contents/PlugIns/platforms/libqcocoa.dylib
Expected in: /Users/manuel/Qt/5.8/clang_64/lib/QtCore.framework/Versions/5/QtCore_debug
Stack trace :
1 __abort_with_payload 0x1001089ee
2 abort_with_payload_wrapper_internal 0x10010843b
3 abort_with_payload 0x100108464
4 dyld::halt(const char *) 0x1000e3793
5 dyld::fastBindLazySymbol(ImageLoader * *, unsigned long) 0x1000e389e
6 dyld_stub_binder 0x7fffce62f282
7 None 0x1045f2008
8 ___lldb_unnamed_symbol1006$$libqcocoa.dylib 0x1044cba06
9 ___lldb_unnamed_symbol24$$libqcocoa.dylib 0x104489ef9
10 ___lldb_unnamed_symbol5$$libqcocoa.dylib 0x10448888e
11 QPlatformIntegrationPlugin::create(QString const&, QStringList const&, int&, char * *) qplatformintegrationplugin.cpp 64 0x1023aa358
12 QPlatformIntegration * qLoadPlugin<QPlatformIntegration, QPlatformIntegrationPlugin, QStringList const&, int&, char * *&>(QFactoryLoader const *, QString const&, QStringList const&&&, int&&&, char * *&&&) qfactoryloader_p.h 101 0x1023a9877
13 QPlatformIntegrationFactory::create(QString const&, QStringList const&, int&, char * *, QString const&) qplatformintegrationfactory.cpp 71 0x1023a9122
14 init_platform(QString const&, QString const&, QString const&, int&, char * *) qguiapplication.cpp 1115 0x1023b9b0b
15 QGuiApplicationPrivate::createPlatformIntegration() qguiapplication.cpp 1278 0x1023b9906
16 QGuiApplicationPrivate::createEventDispatcher() qguiapplication.cpp 1295 0x1023ba33f
17 QApplicationPrivate::createEventDispatcher() qapplication.cpp 188 0x102bce165
18 QCoreApplicationPrivate::init() qcoreapplication.cpp 787 0x101dd2be5
19 QGuiApplicationPrivate::init() qguiapplication.cpp 1318 0x1023b71d5
20 QApplicationPrivate::init() qapplication.cpp 568 0x102bce7af
Used compiler :
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ --version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
What could be the cause ? How to fix this ?
I have a cross platform console application. The purpose of it is to transfer data between two peers. Sometimes packets received are not complete so we append the data into a string while the complete packet has been arrived. But it get crashed in appending data in string after sometime. Here is the back tarce -
1 libsystem_c.dylib 0x93b77acf pthread_kill + 101
2 libsystem_c.dylib 0x93bae4f8 abort + 168
3 libc++abi.dylib 0x9698180c abort_message + 151
4 libc++abi.dylib 0x9697f275 default_terminate() + 34
5 libc++abi.dylib 0x9697f2b5 safe_handler_caller(void (*)()) + 13
6 libc++abi.dylib 0x9697f31d std::terminate() + 23
7 libc++abi.dylib 0x96980412 __cxa_throw + 110
8 libstdc++.6.dylib 0x90e23d6c std::__throw_length_error(char const*) + 104
9 libstdc++.6.dylib 0x90e4f3a9 std::string::append(char const*, unsigned long) + 175
10 libConnector.dylib 0x13905228 ConnectionSocket::AdjustPartialData(char const*, int)
14 libConnector.dylib 0x1383e0b6 ConnectionChannel::ProcessData(int, void const*, int, char*, int) + 7886
15 libConnector.dylib 0x13861ecb ConnectionManager::BaseThreadImpl() + 1185
16 libConnector.dylib 0x13861a23 ConnectionManager::BaseThread(void*) + 17
17 libsystem_c.dylib 0x93b76557 _pthread_start + 344
18 libsystem_c.dylib 0x93b60cee thread_start + 34
Can someone give any idea about this issue?
EXAMPLE CODE:
AdjustPartialData(char* const pData, int dataLen)
{
if (true == packetIncomplete)
{
partialDataBuffer.append(pData, dataLen); // crash occurs in this line
}
}
if partialDataBuffer.size() + dataLen > partialDataBuffer.max_size() then append throws a length_error (http://en.cppreference.com/w/cpp/string/basic_string/append)
Either partialDataBuffer or dataLen are too big.
Finally I have resolved the issue by discarding the extra data which causes the overflow. Previously I thought this will not be feasible solution as it could lead to possible data loss. But I found that TCP stream size shouldn't be greater than 65535 which is 16 bit. But found another issue when the following condition added -
if(partialDataBuffer.size() + dataLen >= partialDataBuffer.max_size())
{
// do not append data
}
else partialDataBuffer.append(pData, dataLen);
The issue was in windows platform it always crashes even though size of partialDataBuffer is much less than partialDataBuffer.max_size(). So, for resolving this issue I have done the following -
try{
partialDataBuffer.append(pData, dataLen);
}
catch(...)
{
// got exception, return
}
And it worked fine for me.
N.B: I have posted my answer because it will be helpful for others who are facing similar issue.
i am executing the stored procedure from c++ as below:
dbsqlexec(_bsmdb);
when i execute the stored procedure from command line it gives me proper output.
2> declare #apicounter int
exec CapApi_CountTgRxObjects #apicounter output, 'subnetwork="NETSim_BAG",bsc=3> "BAG01",site="RS8000#0",mo="RXOTG-0",%'
4> go
(return status = 0)
Return parameters:
-----------
9
(1 row affected)
but in c++ code its giving me core dump.
below is the stored procedure.
CREATE PROCEDURE CapApi_CountTgRxObjects (#count_out int output,#tgdn_in varchar
(200))
AS
BEGIN
declare #likeGE varchar(200),
#likeLT varchar(200),
#rc int
/*
** Build the simulated like strings
*/
exec #rc =
CapApi_likeFix #likeStr=#tgdn_in, #likeGE=#likeGE OUT, #likeLT=#likeLT OUT
if (#rc != 0)
begin
return 1
end
/*
** Execute the Worker procedure
*/
exec CapApi_CountTgRxObjectsW #count_out=#count_out OUT, #tgdn_GE=#like
GE, #tgdn_LT=#likeLT
/*
** Normal exit point
*/
return 0
END
(3 rows affected)
(return status = 0)
The core trace is below:
----------------- lwp# 1 / thread# 1 --------------------
fcb16576 t_splay (140e6958) + 1f
fcb16454 t_delete (140e6958) + 2a
fcb1618e realfree (140e6918) + 58
fcb16797 cleanfree (0) + 44
fcb15cb3 _malloc_unlocked (8, 83df9d0, 140e68c8, fc4df378, 802a988, fc44ee9b) + ad
fcb15bdc malloc (4) + 34
fc44ee9b comn_malloc (4) + 1b
fc438012 dbsvretval (83df9d0) + 3f6
fc4369c5 dbsqlok (83df9d0) + 115
fc436668 dbsqlexec (83df9d0, 0) + 30
fec1c19f __1cICACCC_tgWCheck_BTS_capabilities6FrnGcna_Mo_ri_v_ (802c24c, 821cc40) + 3ff
fec1d4a2 __1cICACCC_tgOPerform_checks6FrnGcna_Mo_ri_v_ (802c24c, 821cc40) + 272
fec16953 __1cICACCC_tgNDirect_checks6FrknGvector4CpnGcna_MO___rikikb_v_ (802c2b8, 821cc40, 2, 0, 0, 0) + 3c3
feaa760d __1cJCACCC_bscNDirect_checks6FpnTCACCC_consist_check_rknGvector4CpnGcna_MO___rikikbrfkf_v_ (821cc28, 802c4b0, 821cc40, 2, 0, 821cc54) + 64d
fe9b25ae __1cTCACCC_consist_checkJcheck_bsc6M_v_ (821cc28, 0) + 17e
fe9ac7de __1cTCACCC_consist_checkNcheck_perform6M_i_ (821cc28, 0) + 14e
fe9acd2b __1cTCACCC_consist_checkFcheck6M_i_ (821cc28, 0) + 9b
0805c656 main (2, 802d1ac, 802d1b8, 802d1a0) + 11a6
08051ebd _start (2, 802d95c, 802d97d, 0, 802d993, 802d9cb) + 7d
----------------- lwp# 2 / thread# 2 --------------------
fcb7ae55 ___nanosleep (78) + 15
fd52a4c2 run (821f668) + 1a2
fcb7875b _thr_setup (fc040200) + 4e
fcb78a60 _lwp_start (fc040200, 0, 0, fbffeff8, fcb78a60, fc040200)
Could anybody please help me finding the problem.....
It looks like your heap is corrupt (it's dying down inside mallocs free-store management code, not in anything DB-related).
Try using a memory-checker tool to identify when the heap gets corrupted (such as Purify if you have it, or IIRC Solaris has a drop-in replacement debugging malloc lib).
This is a C++ bug, unrelated to the stored proc.
Try using libumem, if it is a corruption is due to double delete, it can be easily found. Here is the link.
http://developers.sun.com/solaris/articles/libumem_library.html
You don't even need to recompile the code, just define the variables mentioned in the link in the startup script.